Pythagorean Triplet in an array | GeeksforGeeks

  Рет қаралды 33,453

GeeksforGeeks

GeeksforGeeks

Күн бұрын

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_1034
@__topgun_1034 2 жыл бұрын
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
@yazanshakhshir3049
@yazanshakhshir3049 6 жыл бұрын
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.
@yazanshakhshir3049
@yazanshakhshir3049 6 жыл бұрын
notice : i think this method has a disadvantage that it requires an additional space O(n).
@reyou7
@reyou7 7 жыл бұрын
Very interesting problem, and nice solution!
@kk-gk2bz
@kk-gk2bz 8 жыл бұрын
Nice video. I'm interested in creating such videos. Can you tell me how to create a video of this type????
@GeeksforGeeksVideos
@GeeksforGeeksVideos 7 жыл бұрын
Please drop us an email on videos@geeksforgeeks.org if you are interested in creating such videos. We are actively looking for contributors.
@ankitadixit5875
@ankitadixit5875 5 жыл бұрын
why i loop going upto
@anjalis8483
@anjalis8483 5 жыл бұрын
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.
@vinaykenguva362
@vinaykenguva362 4 жыл бұрын
this can be solved in n(logn)
@adityaraj5200
@adityaraj5200 3 жыл бұрын
Can u explain , how?
@adityagoel2739
@adityagoel2739 2 жыл бұрын
What if there are negative numbers
@harshjoshi6257
@harshjoshi6257 4 жыл бұрын
harkirat?
@biplabroy1406
@biplabroy1406 4 жыл бұрын
there can be more better approach in nlogn time... There is some more interesting thing about pyhth. triplets
@__topgun_1034
@__topgun_1034 2 жыл бұрын
Would you plz elaborate . I am very curious to know what things your talking about
@arshneetkathuria1757
@arshneetkathuria1757 3 жыл бұрын
in the naive approach each of the loop should begin from 0 index....yours will give false answer
@nabeelnavab1282
@nabeelnavab1282 3 жыл бұрын
;(
@rajitsrajan2644
@rajitsrajan2644 3 жыл бұрын
I think the third loop should also start from i+1, do'nt think any other change is required.
@akshaykumar192
@akshaykumar192 Жыл бұрын
Nic
@abhishekjaiswal6492
@abhishekjaiswal6492 3 жыл бұрын
worst way of illustrating ...............
Segregate 0s and 1s in an array | GeeksforGeeks
8:04
GeeksforGeeks
Рет қаралды 31 М.
Floor and Ceiling in a sorted array | GeeksforGeeks
10:37
GeeksforGeeks
Рет қаралды 21 М.
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 15 МЛН
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 38 МЛН
Maximum Length Bitonic Subarray | GeeksforGeeks
13:05
GeeksforGeeks
Рет қаралды 15 М.
Genetic Algorithms Explained By Example
11:52
Kie Codes
Рет қаралды 319 М.
Count minimum steps to get the given desired array | GeeksforGeeks
8:43
Linked lists in 4 minutes
4:22
Michael Sambol
Рет қаралды 66 М.
Selection sort algorithm
10:18
mycodeschool
Рет қаралды 1,2 МЛН
Equilibrium index of an array | GeeksforGeeks
5:08
GeeksforGeeks
Рет қаралды 27 М.
Find the minimum distance between two numbers | GeeksforGeeks
15:56
GeeksforGeeks
Рет қаралды 65 М.
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН