Subset Sum Problem using Dynamic Programming | Data Structures and Algorithms

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 154

  • @somsk56
    @somsk56 6 місяців тому +19

    I was stuck since 3 days in this tabulation method after watching Striver , But You are life saver of mine Maam. thanks Maam . Boss is always Boss.

  • @vinodkumar-ds2po
    @vinodkumar-ds2po 5 років тому +31

    I came across lots of videos on the internet for this particular problem, but none of them were able to explain in such a decent and nice way like you. Very well explained, thanks a lot :)

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

      Kidding?

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

      @@arunakampati4365 Worst hai woh. Bas outdated C language ka incomplete pseudocode deta hai. Waise toh hum bhi explain kare par ek code karke dikhaiyye ? Wastage of time on his videos

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

      Dhjrfklkyggfcszcjo

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

      @@pg9645 C language is outdated?

    • @ABCD-gn5uw
      @ABCD-gn5uw 3 роки тому +3

      @@sdwysc to be honest he should have shown the implementation as well. i love his way of explaining but a implementation would be cherry on cake.

  • @justadev____7232
    @justadev____7232 5 років тому +13

    Best explanation I've found on this algorithm. I spent over 2 hours watching other videos without being able to grasp it. Came across this one and it clicked!! Thank you!!

  • @KhushiJain-xx2yk
    @KhushiJain-xx2yk 2 роки тому +8

    Best tutor I have ever seen on UA-cam 🤗🤗you're amazing ma'am

  • @NikitaNair
    @NikitaNair 2 місяці тому +1

    The table filling is finally crystal clear now!! Thank you so much ma'am, you are a life saver :)

  • @smilingsna4462
    @smilingsna4462 Рік тому +2

    Thank you ma'am so much 😊 I searched a lot about this problem I didn't find a single solution as your so thank you so for explaining it in detail 🙂🙂

  • @priyankataneja7347
    @priyankataneja7347 4 роки тому +18

    This video explains whether sum exists or not. Can you explain how can we find pairs. Which all set of elements form the sum,. For Example - {1,3,5,7,10,2,6} - Target Sum - 12 Answer should be - (1,5,6) (10,2 )(5,7)(6,2,3,1). How can we find this thing from this matrix?? Could you please explain this??

  • @ChandrakalaCheduluri
    @ChandrakalaCheduluri 2 місяці тому

    I love the way that you are teaching mam and it is very useful for me thank you mam❤😊

  • @rze_rash
    @rze_rash 2 місяці тому

    love u mam , really best teacher ☺☺☺☺☺☺☺☺

  • @baibhavvikas1767
    @baibhavvikas1767 3 роки тому +2

    Thank you ,mam for such an amazing explanation .It solved all my doubts. Apart from other who just showed how to write code u explained how to fill the table in a really fantastic way

  • @velakuruday
    @velakuruday Рік тому

    Thank you sister. You explained in a slow and clear way.

  • @NarayanBhuyan-v6y
    @NarayanBhuyan-v6y 5 місяців тому +1

    hello mam very sweet of that u explain each part of the problem that every student is stuck with ,,but there is only one problem is that your board is not properly visible coz of focus,,,,,

  • @GulshanKumar-jd2dm
    @GulshanKumar-jd2dm 4 роки тому +1

    Nice explanation mam. U also make easier for writing code.
    Lot of thanks mam😊😊

  • @shivamsharma-oi3gn
    @shivamsharma-oi3gn 4 місяці тому

    Ohhhh man 😭 !! Thank you so much, bestest explanation of this question🤞

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

    Mam U r teaching style is very good

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

    first of all thank you very much for your explanation ,but small suggestion instead of directly hitting the solution kindly try to explain the logic behind that i.e why we are following Dp approach to solve this why Backtracking is not good.
    IT's like How we can solve this question???
    And your answer is DP.
    But Y?

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

      Actually I have discussed the need of DP in one of my videos... U can check out the playlist Dynamic Programming..

  • @vaibhavgarg4267
    @vaibhavgarg4267 5 років тому +12

    @Jenny it will be helpful if you can explain how to deduce that we should be creating table in this manner? And, how it is concluded that we need to use this formula? This would help in actual logic building.

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

      Probably she doesn't know and have only by hearted it and started teaching

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

    *Amazing explanation saved my lot of time thanx mam* :)

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

    Thank you ma'am👍 for this concept🙂

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

    Tc mam 🤟🏻🖤 its very useful lect. Mam
    .thank you very much .🖤

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

    Beautifully explain by you

  • @rishabhkumar7179
    @rishabhkumar7179 5 років тому +8

    Maim please upload the second video of this to find out the particular subset 🙏

  • @tienthanhpham4596
    @tienthanhpham4596 4 роки тому +2

    Your algorithm videos have helped me alot, I'm grateful to you. If you have time, could you make some videos of backtracking?

  • @karthikrangaraju9421
    @karthikrangaraju9421 5 років тому +3

    Why people don't explain the intuition behind problems? :( Can you explain WHY we take value just from above cell vs taking value from the delta????

  • @IITian-NITian_0305
    @IITian-NITian_0305 4 роки тому +1

    Great mam.....

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

    Hello, thanks a lot for the explanation. Just wanted to know why are all elements set to true for sum 0.

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

    Great Explanation

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

    great but I did not understand how the sum can be equal to zero (first column) if I select A[i] at minute 6:30.

  • @ShivamSharma-lr2lr
    @ShivamSharma-lr2lr 4 роки тому

    Thank you so much mam🙏🙏

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

    Hello Riya , teaching very good

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

    Thanks for great interpretation!

  • @c.danielpremkumar8495
    @c.danielpremkumar8495 5 років тому +1

    Excellent !

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

    thank you! very useful

  • @Kepp-w6r
    @Kepp-w6r 5 років тому +6

    please make a video of how to find a subset thank you..

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

      Use backtracking .. go back from the last column last row 1 and note down the row numbers as you proceed back .. you will get the subset

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

    great explanation

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

    Very Good ma'am

  • @clasher9667
    @clasher9667 5 місяців тому

    Thank you very much

  • @memd777
    @memd777 4 роки тому +2

    is it necessary that the Array A = 2,3,5,7,10 needs to be sorted for this to work?

    • @ramakrishna-jk2jl
      @ramakrishna-jk2jl 3 роки тому +1

      No need, it will work with unsorted array as well.

  • @harrietobwogo720
    @harrietobwogo720 4 роки тому +2

    Hey Jenny this approach works if your array has only positive integers..what happens in the case of negative integers being in your list?

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

    Mam as per your formula sum-A[i] , when sum=8 and arr[i]=7 --> sum-A[i]=1 and in above row A[1]=0 then how could you can write 1 there, please explain mam

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

    Thank you. well explained.

  • @maheshpatil-pf2fd
    @maheshpatil-pf2fd 3 роки тому +1

    does the element of the should be return in sorted manner

    • @ramakrishna-jk2jl
      @ramakrishna-jk2jl 3 роки тому

      No need, it will work with unsorted array as well.

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

    jenny the video is very help full about what we have to do , but it doesn't speaks any anything about Why we are doing it eg at 8:56 it says we have to do sum- A[i] but its not very clear why we are doing it why not Sum- A[j] or A[i]-A[j] ?

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

    Great video👌😍, plz upload a series on Fibonacci heap and binomial heap
    I'll greatly appreciate it.
    Thanks 🙏

  • @Infernal_Crimson
    @Infernal_Crimson 8 днів тому

    Shoutout to all those students watching this video in 1x.. i.e they are that early to have the luxury to do so..

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

    Excellent Explanation. You are requested to use better quality of marker

  • @prachiuppal3612
    @prachiuppal3612 Місяць тому

    mam here also we have to sort the elements of the array or not????

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

    Cute mam,,cute explanation..
    Love u mam.

  • @jrseinc
    @jrseinc 5 років тому +3

    very good explination. I have one question: Is it necessary that the set should be in increasing order for creating DP table?

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

      Yes otherwise the maximum sum will yhe sum of all positive number in the array

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

    can you give the link of the video in which you have calculated the subset of thhe sum.

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

    Thanks for explanation. Can you please tell how to arrive at this solution. In dp, each and every problems seem to be solved differently. It would be helpful if you can explain that. Thanks

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

    Many many thanks!!

  • @kunjeyan_5875
    @kunjeyan_5875 5 років тому +3

    Very nice explanation.. Loved it... But Ma'am, please explain why we are going to one cell back and then subtracting the value of i and getting the value of that cell (if the value in previous cell is 0) and if it is 1 we directly copy 1....please explain the logic behind this.

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

      you are targeting to get sum listed on top row. when your cell value is [left column] less than sum you are looking for, you are going back and see whether that difference can be achieved, by looking at that cell [the sum value listed in the top]

  • @ivandrofly
    @ivandrofly 9 місяців тому

    Why we need to row-1? Why not taking from current row? The value for row is already computed

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

    nice explanation mam

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

    can u plz explain why u write 1 in column having value 0 ?
    what i understand is if we write 1 means we can make a subset and by having subset with value 2 or other, sum will not be 0.
    plz explain it

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

    it was such a great video mam.Can you make videos on Greedy Algorithms??

  • @singhscribe7450
    @singhscribe7450 Рік тому

    kindly mention the error in the table's last row and column where it shall be 0.
    If I am wrong, please let me know.

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

    THE İMPLEMENTATİON İS NOT CORRECT SİNCE A[i][j-A[i]] part is the reason of array index out of exception error but the explanation is correct
    the easiest way of implementtaion of this problem is recursive

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

    thanks

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

    Mam, what is the time and space complexity of this algo?

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

    24:41 , it will be A [ i - 1 ] [ j - A (i - 1) ] = 1

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

      it is [i-1] in the first block because we are considering the previous row.. but when we are subtracting j-A(i) we are subtracting A(i) from the current row.. So j-A(i) is correct

  • @kishanpandey5219
    @kishanpandey5219 2 роки тому +1

    If the sum is given 50 then .....will these tables still be feasible?

  • @dr.nehajain1366
    @dr.nehajain1366 2 роки тому

    Awesome

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

    If the sum value is high it will be very complex to solve in dp . Is it any other method better than dp in that case?

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

    Thank you mam

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

    ma'am please make a video on square root decomposition

  • @bhogeswarasaikumar6351
    @bhogeswarasaikumar6351 5 років тому +2

    How to find those subsets?

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

    mam how can we include the element when sum is 0

  • @Charlie-jx6mv
    @Charlie-jx6mv 5 років тому

    Divide and conquer leads dividing main problem in to subproblems...

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

    Can you solve it with State space tree

  • @SOURAVKUMAR-ps4zr
    @SOURAVKUMAR-ps4zr 5 років тому +2

    Mam please give me an example of back-tracking

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

    Mam please make the part two of the subset sum problem.

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

    what if the asked weight is too large like 100 or something, then we need to prepare a table for that. Not sure if DP should be used here.

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

    is this method using back tracking ?

  • @RajivKumar-qd9bw
    @RajivKumar-qd9bw 2 місяці тому

    In last row that is for filling for row 10 ,how you put 1 for element 14 bcz,14-10= 4 and the value of 4 is 0 in above row . though we can make 14 with help of these elements but formula fails here for filling for 14

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

    Will it work if the sum is odd number? I wrote code on my own based on your explanation. It is not working if the sum is odd number.

  • @sachink.s838
    @sachink.s838 4 роки тому

    mam plz explain print all subset

  • @biswajitsahu7565
    @biswajitsahu7565 5 років тому +2

    mam,Where is the 2nd part!¿

  • @govardhansai8838
    @govardhansai8838 2 місяці тому

    mam you are explanation was amazing but,it might be better if you have provided code of this

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

    Mam, please avoid uploading in just 360p. It might appear fine now but people would hit dislike on your Good content when era of 5g and 4K arrives. Think long term for your channel.

  • @AnandKumar-ro1yd
    @AnandKumar-ro1yd 4 роки тому

    Could you make more videos on problem solving and Dynamic problem

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

    Mam please make videos on oops concepts in Java

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

    Mam can you do video on subset program

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

    Mam please upload more problems on dynamic Programming

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

    Hello mam.. Is this solve by using backtracking

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

    Ma'am at @20:15 u said there will be another video of subset problem
    Can u please give link for the same
    Thank u in advance

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

    can you explain me how to solve any problem by using dynamic programming ..

  • @kattelanithyasri7727
    @kattelanithyasri7727 Рік тому

    how to print those subsets, please help

  • @AbhishekKumar-im2xd
    @AbhishekKumar-im2xd 4 роки тому

    another method is using bitsets::)
    ll N;
    cin>>N;
    vector arr(N);
    for(auto& it : arr) cin>>it;
    bitset b(0);
    b[0]=1;
    for(auto x : arr)
    b |= (b

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

    Explanation is good but this is not a right way to teach DP. First we need to understand the recursive logic and when the recursive logic is developed then only we can made a DP solution. Video like this did not include basics of DP and no can solve questions of DP directly by making a table. If you do not know which problem is overlapping then how you can do so.

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

    mam particular subset second vedios plz

  • @selva140
    @selva140 Рік тому

    why you choose other elem for the sum=0

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

    how does it work?

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

    Plzz make more videos on DP

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

    Mam what if the we have given sum like 245

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

    What if array is not sorted

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

    Mam plz put queen problem

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

    Mam I guess in the place A[i]=3 and sum(j) =4 should be 1 😅

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

    please upload hd video quality