Explanation for the article: www.geeksforgeeks.org/find-pyt... Read More: www.geeksforgeeks.org/find-py... Practice Problem Online Judge: practice.geeksforgeeks.org/pro... This video is contributed by Harshit Jain.
Пікірлер: 20
@__topgun_10342 жыл бұрын
Question didn't mention that a,b,c should be distinct . Question says array is of type integers so if there is 0 in array , we could get multiple triplets with duplicate values. Ex . In array (0,3,4). Triplets would be(0,0,0),(0,3,3) (0,4,4) . I have written triplets in order of(a,b,c) respectively This case won't effect code,code would give right output in this case to. But it's just that I was concerned about if the question is asked considering the case I mentioned above
@yazanshakhshir30496 жыл бұрын
another solution that might work is to fill the squared array elements in a hashmap making the index the squared element which takes O(n) then in a nested loop , for each element (i) in the squared elements Array search in the hashmap if the "absolute difference" between A[i] and A[j] exists in the hashmap , if so, then we have a Pythagorean triple.
@yazanshakhshir30496 жыл бұрын
notice : i think this method has a disadvantage that it requires an additional space O(n).
@reyou77 жыл бұрын
Very interesting problem, and nice solution!
@kk-gk2bz8 жыл бұрын
Nice video. I'm interested in creating such videos. Can you tell me how to create a video of this type????
@GeeksforGeeksVideos7 жыл бұрын
Please drop us an email on videos@geeksforgeeks.org if you are interested in creating such videos. We are actively looking for contributors.
@ankitadixit58755 жыл бұрын
why i loop going upto
@anjalis84835 жыл бұрын
Because the first two elements will be picked by the inner while loop to see if their sum is equal to the element picked by the for loop.
@vinaykenguva3624 жыл бұрын
this can be solved in n(logn)
@adityaraj52003 жыл бұрын
Can u explain , how?
@adityagoel27392 жыл бұрын
What if there are negative numbers
@harshjoshi62574 жыл бұрын
harkirat?
@biplabroy14064 жыл бұрын
there can be more better approach in nlogn time... There is some more interesting thing about pyhth. triplets
@__topgun_10342 жыл бұрын
Would you plz elaborate . I am very curious to know what things your talking about
@arshneetkathuria17573 жыл бұрын
in the naive approach each of the loop should begin from 0 index....yours will give false answer
@nabeelnavab12823 жыл бұрын
;(
@rajitsrajan26443 жыл бұрын
I think the third loop should also start from i+1, do'nt think any other change is required.