aradhyakanth.mail Q.) All Pythagorean Triplets in an array. Time complexity : O(n^2) Space complexity: O(1) #include #include using namespace std; int main(){ int arr[] = {3, 1, 4, 6, 7, 8, 10}; int n = sizeof(arr)/sizeof(arr[0]); for(int i=0;i=2){ int l = 0; int r = i-1; while(l != r){ if ((arr[l] + arr[r]) arr[i]){ r–; } else{ cout << "True"; return 1; } } i–; } cout << "False"; return 0; } Log in to Reply
PrepInsta Support Hi Ramya, Thank You for your feedback. You can practice our more coding question from other Companies Pages like Cognizant or TCS etc as we have totally different question. Log in to Reply
Q.) All Pythagorean Triplets in an array.
Time complexity : O(n^2)
Space complexity: O(1)
#include
#include
using namespace std;
int main(){
int arr[] = {3, 1, 4, 6, 7, 8, 10};
int n = sizeof(arr)/sizeof(arr[0]);
for(int i=0;i=2){
int l = 0;
int r = i-1;
while(l != r){
if ((arr[l] + arr[r]) arr[i]){
r–;
}
else{
cout << "True";
return 1;
}
}
i–;
}
cout << "False";
return 0;
}
i have a coding part on Hackerrank waht shoul i do??
can gain more knowledge…..very useful
Hi Ramya,
Thank You for your feedback. You can practice our more coding question from other Companies Pages like Cognizant or TCS etc as we have totally different question.
This test is useful for all
Questions
Questions
Had a Good experience