Find the pair in array whose sum is closest to x | GeeksforGeeks
Вставка
- Опубліковано 29 чер 2017
- Find Complete Code at GeeksforGeeks Article: www.geeksforgeeks.org/given-so...
Similar Video: • Given an array A[] and...
This video is contributed by Parikshit Kumar Pruthi
Please Like, Comment and Share the Video among your friends.
Also, Subscribe if you haven't already! :)
This double pointer technique seems to pop as solution to many problems with small variations e.g. finding the longest sub-sequence of unique elements.
Is there a general principal of when you can frame the problem as such?
Ya actually needed.
use binary search
Can u plz provide code in c language
why are you screaming bro?
True Don't know why he screaming. It can be explained in must easier fashion.
its like reading something loudly :)
Fix the video - the most basic fact in "Efficient Solution" is missing that the array must be sorted.
Well, the problem statement itself says, "Given a sorted array..."
its not working when number x is in the array
ex:
int arr[] = { 10, 20, 5, 4, 2, 1 }, x = 10;
it gives 10 and 1, it should 5 and 4
The array should be sorted first!! Read the problem statement
@@rupampaul Exactly
Thanks for the solution. If you are sorting the array then sorting dominates the complexity , so wont that be O(n log n)
Open your eyes and see the initial slide, it says given already sorted array
lets say u did merge sort...then it is O(n Log n), still the same.
anyway watch my videos :)
please can you provide the code in R language
what is r language
@@Itshristi used for data scientists, statisticians
Pl