No video

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
@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).
@__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
@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.
@adityagoel2739
@adityagoel2739 2 жыл бұрын
What if there are negative numbers
@vinaykenguva362
@vinaykenguva362 4 жыл бұрын
this can be solved in n(logn)
@adityaraj5200
@adityaraj5200 3 жыл бұрын
Can u explain , how?
@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.
@harshjoshi6257
@harshjoshi6257 4 жыл бұрын
harkirat?
@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.
@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
@akshaykumar192
@akshaykumar192 Жыл бұрын
Nic
@abhishekjaiswal6492
@abhishekjaiswal6492 3 жыл бұрын
worst way of illustrating ...............
Segregate 0s and 1s in an array | GeeksforGeeks
8:04
GeeksforGeeks
Рет қаралды 31 М.
Find equilibrium point in an array
10:32
Techdose
Рет қаралды 54 М.
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 21 МЛН
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 195 МЛН
Little Man Computer: 1. Introduction
20:09
Computer Science
Рет қаралды 35 М.
Genetic Algorithms Explained By Example
11:52
Kie Codes
Рет қаралды 319 М.
Union and Intersection of two sorted arrays | GeeksforGeeks
10:02
GeeksforGeeks
Рет қаралды 147 М.
Number Theory | Primitive Pythagorean Triples
19:50
Michael Penn
Рет қаралды 47 М.
Maximum Length Bitonic Subarray | GeeksforGeeks
13:05
GeeksforGeeks
Рет қаралды 15 М.
Linked lists in 4 minutes
4:22
Michael Sambol
Рет қаралды 66 М.
Equilibrium index of an array | GeeksforGeeks
5:08
GeeksforGeeks
Рет қаралды 27 М.
Inserting an element in an array (C program)
7:16
CSE GURUS
Рет қаралды 85 М.
Find the minimum distance between two numbers | GeeksforGeeks
15:56
GeeksforGeeks
Рет қаралды 65 М.