Meet in the middle algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 เม.ย. 2023
  • This video explains the meet in the middle algorithm which is a very unique algorithm used to find the closest subsequence sum. It requires you to know finding all possible subset sums and use of binary search lowerbound. A practice problem for this algo is leetcode 1755.
    CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ======================================PLEASE DONATE=============================
    🧡 SUPPORT OUR WORK: / techdose
    💚 UPI-ID: surya.kahar@ybl
    💞JOIN Membership: / @techdose4u
    ==============================================================================
    INSTAGRAM : / surya.pratap.k
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithTECHDOSE
    TELEGRAM Group LINK: t.me/joinchat/SRVOIxWR4sRIVv5...
    =======================================================================
    USEFUL LINKS:
    🟠Must do TIPS to ACE Virtual Interview: • 🔴Must do Tips to ACE y...
    🟢Best strategy to excel your coding interview: • 🔴Best strategy to exce...
    🟡Get your dream job in 1 month: • 🔴Get your dream job in...
    🔵How to crack dream job in just 2 months: • How to crack dream job...
    🟣7 Days DSA plan: techdose.co.in/7-days-dsa-che...
    RELATED LINKS:
    CODE LINK: gist.github.com/SuryaPratapK/...

ความคิดเห็น • 30

  • @sumitkumarmahto5081
    @sumitkumarmahto5081 6 หลายเดือนก่อน +7

    The video's Heading is Meet in the middle algorithm, but you never really explained why this is called meet in the middle algorithm ? what is the intuition behind it ? how can this idea be generalized to other such problems ?

  • @saumyaranjan9256
    @saumyaranjan9256 ปีที่แล้ว +1

    Really clear and concise on the explanation part. The thing which helped most was the way in which you had prepared the notes beforehand and they really addressed every part of the problem and the algorithm as to why is it beneficial to use this in this particular case.
    Thank You!

  • @surendharv795
    @surendharv795 หลายเดือนก่อน +1

    4:04 Sir, One Small correction in the video.
    The closeset sum can be great than the goal , but should be closest.

  • @jui20oct
    @jui20oct 6 หลายเดือนก่อน +1

    Very clear explanation! Thank you!

  • @shivanggautam541
    @shivanggautam541 9 หลายเดือนก่อน

    very understandable and amazing explanation. thank you very much for the video

  • @hijibiji9471
    @hijibiji9471 ปีที่แล้ว +5

    lower_bound definition is different if compared with lower_bound stl of cpp

    • @HimanshuSingh-rm5sd
      @HimanshuSingh-rm5sd 9 หลายเดือนก่อน

      yes it gives arr[i] > = target with smallest i value

  • @HimanshuSingh-rm5sd
    @HimanshuSingh-rm5sd 9 หลายเดือนก่อน +1

    @techdose sir lower_bound definition is different in this case for 13 it wil return n size of array

  • @casinarro
    @casinarro ปีที่แล้ว +3

    really neat and systematic explanation. This channel is a gem!! Thanks a lot, will continue watching and refer the channel to my friends.

  • @bharat_india12
    @bharat_india12 ปีที่แล้ว

    Good explanation

  • @Lucifer-xt7un
    @Lucifer-xt7un ปีที่แล้ว

    Sir please please upload a sheet for complete beginners which support to join your course

  • @vivekpatwal4655
    @vivekpatwal4655 5 หลายเดือนก่อน

    beautiful sirrr

  • @yogeeshrsyogeeshrs4204
    @yogeeshrsyogeeshrs4204 ปีที่แล้ว +1

    Yes I am also requesting you to make videos on greedy technique it will be beneficial in the interview please

  • @kushalkushal8458
    @kushalkushal8458 11 หลายเดือนก่อน

    Thanks a lot

  • @sdmfslkdm
    @sdmfslkdm 6 หลายเดือนก่อน +1

    how does deviding the arrray into two parts explore all subset sums ?
    for eg -> 3 + (-2) = 1 is missing !

    • @techdose4u
      @techdose4u  6 หลายเดือนก่อน

      What’s your example?
      Please elaborate

  • @sonumondal9376
    @sonumondal9376 ปีที่แล้ว +2

    One request sir your videos are really beneficial but can you make more videos for greedy playlist plzzz plzz

  • @harisai3580
    @harisai3580 6 หลายเดือนก่อน +1

    Anybody seeing my comment pls answer my doubt that is subset sum problem works only for positive numbers right or it works for any integers ? pls........

    • @techdose4u
      @techdose4u  6 หลายเดือนก่อน

      It can be made to work but the complexity will be much more.
      Ex. (-2,-4,2,3)
      Sum range will be -6 to 5 (taking extreme subset sum scenarios).
      Now, cols must denote sum.
      So, No of cols = mod(6)+mod(5)+1(for 0) = 12 cols
      -6 will be made to map to 0.
      You can note that space complexity is large.
      If a sum goes beyond target sum still it can come back due to negative numbers ahead.
      Therefore, if you give enough space then YES you can solve it :)
      Peace!

  • @ayushsaxena5505
    @ayushsaxena5505 ปีที่แล้ว

    In the code why have you also used the previous element of the lower bound

  • @jatinarora2991
    @jatinarora2991 9 หลายเดือนก่อน

    why subset sum is not a feasible soln can you explain. If we use binary seach with subset sum(using dp) then it can be solved in log(sum)*sum*N right ?

    • @techdose4u
      @techdose4u  9 หลายเดือนก่อน

      Space complexity ?

  • @amboojmittal2993
    @amboojmittal2993 ปีที่แล้ว

    We have considered time complexcity of sorting the right half

  • @siddharth892
    @siddharth892 6 หลายเดือนก่อน

    Why would the dp not work though?

    • @AnujGupta-xi5ep
      @AnujGupta-xi5ep 4 หลายเดือนก่อน

      For negative elements in the array, dp matrix can't store negative index, hence it won't work.