1. Square each element of the array and then sort it---------------O(nlogn) 2. for(i=0;i<(size-3);i++) { j=i+1; k=size-1; while(j<k) { if(a[[i] + a[j] == a[k]) printf("\n%d %d %d",sqrt(a[i]),sqrt(a[j]),sqrt(a[k])); else if(a[i] + a[j] < a[k]) j++; else k--; } }------------------------------------------------------------------------O(n^2)
Time O(n^2) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.