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! :)

КОМЕНТАРІ • 21

  • @CristianGarcia
    @CristianGarcia 4 роки тому +3

    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?

  • @wecan2729
    @wecan2729 3 роки тому +1

    use binary search

  • @NaveenKumar-ce9vq
    @NaveenKumar-ce9vq 4 роки тому

    Can u plz provide code in c language

  • @SagarAnkitaUpdates
    @SagarAnkitaUpdates 5 років тому +7

    why are you screaming bro?

    • @sabyasachi3389
      @sabyasachi3389 4 роки тому +1

      True Don't know why he screaming. It can be explained in must easier fashion.

  • @terasoft1321
    @terasoft1321 2 роки тому

    its like reading something loudly :)

  • @ambujk1
    @ambujk1 7 років тому +5

    Fix the video - the most basic fact in "Efficient Solution" is missing that the array must be sorted.

    • @GeeksforGeeksVideos
      @GeeksforGeeksVideos  7 років тому +6

      Well, the problem statement itself says, "Given a sorted array..."

  • @masbro1901
    @masbro1901 4 роки тому

    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

    • @rupampaul
      @rupampaul 4 роки тому +1

      The array should be sorted first!! Read the problem statement

    • @ahishnar1568
      @ahishnar1568 3 роки тому

      @@rupampaul Exactly

  • @ketanjoshi4568
    @ketanjoshi4568 5 років тому +1

    Thanks for the solution. If you are sorting the array then sorting dominates the complexity , so wont that be O(n log n)

    • @elvinjafarli6257
      @elvinjafarli6257 5 років тому +1

      Open your eyes and see the initial slide, it says given already sorted array

    • @AvgTuber
      @AvgTuber 2 роки тому

      lets say u did merge sort...then it is O(n Log n), still the same.

    • @AvgTuber
      @AvgTuber 2 роки тому

      anyway watch my videos :)

  • @sudhamshbolisetty01
    @sudhamshbolisetty01 5 років тому

    please can you provide the code in R language

    • @Itshristi
      @Itshristi 5 років тому

      what is r language

    • @elvinjafarli6257
      @elvinjafarli6257 5 років тому

      @@Itshristi used for data scientists, statisticians

  • @abhaygupta2946
    @abhaygupta2946 2 роки тому

    Pl