DP 51. Burst Balloons | Partition DP | Interactive G-Meet Session Update

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ม.ค. 2025

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

  • @spandanrastogi7144
    @spandanrastogi7144 ปีที่แล้ว +127

    This video has saved me two days of scratching my head while trying to understand the solution in discussion section and still moving on with unclear things in my head
    The fact that there were no courses like this to learn from during his time and he must have learnt all this with just pure grind and just hours and hours of work blows my mind.
    He's pouring his years of hard work into these videos and that too for free
    Thank You Striver !

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

    At 22:36 there is mistake it will be mini = max(mini, cost)

    • @k.chetankumar6533
      @k.chetankumar6533 ปีที่แล้ว

      yes upvote every one so that everyone can see this mistake👍

    • @rocklee3254
      @rocklee3254 ปีที่แล้ว +9

      i think striver wanted to use maxi = max(maxi, cost) like he uses always

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

      yah its maxi we need. Just a small mistake guys. it happens at times
      Anyways the point is we need to go in reverse - last 2ndlast 3rdlast....nthlast(aka first)

    • @karthik-varma-1579
      @karthik-varma-1579 5 วันที่ผ่านมา

      maxi = max(maxi, cost)

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

    Your videos have helped me to get to Google. Thanks a lot for making such helpful stuffs.

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

      Bhaiya can you Kindly say how much does cp profile matter for google at 1-2 years of experience? Thank You very much... 🙏

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

      @@abh9789 I didn't had any. I solved the SDE sheet religiously and followed his videos and some other folks videos (techdose and codebix).

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

      @@gopeshkhandelwal9823 May I ask which college are you from? Did you join google as a fresher? Thank You..

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

      @@abh9789 No, I am not a fresher. I had worked with Amazon for 1.5 years earlier after the college.

    • @VY-zt3ph
      @VY-zt3ph 2 ปีที่แล้ว +36

      You proved that we don't need scaler.

  • @Dontpushyour_luck
    @Dontpushyour_luck ปีที่แล้ว +17

    one of the toughest problem so far for me, but as soon as you explained the approach of going from last balloon to first balloon, i was able to code it up myself. All this due to your excellent dp series so far!

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

      Same. The moment he said it, the whole solution struck me. Sadly, I could not come to the conclusion myself.

  • @nilimsankarbora5911
    @nilimsankarbora5911 ปีที่แล้ว +6

    This is one of your best videos!
    Burst Balloons has got to be one of the most complex problems for anyone solving it for the first time, and your explanation makes it clear how the methods we would normally begin with won't work, and why starting from the bottom WILL work.
    Thanks for this video and congrats for making a great one for this problem. ❤❤❤

  • @shlok1124
    @shlok1124 ปีที่แล้ว +11

    This is one of your best videos!
    Burst Balloons has got to be one of the most complex problems for anyone solving it for the first time, and your explanation makes it clear how the methods we would normally begin with won't work, and why starting from the bottom WILL work.
    Thanks for this video and congrats for making a great one for this problem.

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

    Striver, in the tabulation method, you don't need to check the condition (i > j continue), you can start the jth loop from i, and it will work fully fine. Thanks for making such great videos. This DP playlist is the best gift from your side to the community.

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

    Understood, thanks.
    Again, this seems to be straight forwardly explained but there's a huge R&D which you might have done to come up with the solution. Thanks a ton for all the help!

  • @Pritesh-sh21
    @Pritesh-sh21 2 ปีที่แล้ว +9

    18:46 is the moment i was completely shocked I MEAN damn Man, this is BEST EXPLANATION SO FAR. Respect++

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

    Hardest Problem in entire dp series i ever watched . same qn. was asked in Samsung. TY striver :)

  • @bluesteel1
    @bluesteel1 10 หลายเดือนก่อน +6

    There is no way on god's green earth anyone can comeup with this approach under pressure in an interview.

    • @AnushkaGupta-x6w
      @AnushkaGupta-x6w 3 หลายเดือนก่อน +1

      Im a living proof of this😢

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

    Understood. I was a bit confused at first, but then it clicked! Great explanation as always!

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

    FIRST/LASY Guy concept instead of level by level or index by index. Great explanation. Striver is the GOAT of DP.

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

    aaj tak burst balloons nhi samajh paya tha itne logon ki videos dekhi youTube par but apki video se 1 shot me samajh aagya thanks bhai and understood!!! ofc.

  • @348_rahulbehera4
    @348_rahulbehera4 2 ปีที่แล้ว +13

    Hey Striver, Thanks for the wonderful explanation of the problem.
    Can you make more videos on the logic of reverse thinking in DP?

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

    i am now in codenation just because of you striver

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

    UNDERSTOOD.......Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @CoolBoy-tp5bg
    @CoolBoy-tp5bg 5 หลายเดือนก่อน

    I spent whole day in figuring out the solution myself but I couldn't make it.Thank you for great explanation in simplest way.

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

    I never learnt dp in scaler like this. I never knew the recursive version in scaler went with tabulation. Striver bhaiya big fan of you I can shout from top of house you made me learn dp like anything. Even during time of scaler i got rejected in first round of amazon. Now I had cleared three rounds maang is a dream for me you will make it come to reality

  • @AnushkaGupta-x6w
    @AnushkaGupta-x6w 3 หลายเดือนก่อน

    This is very imp question, it was asked in an interview of a really big company with extremely high CTC

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

    i fucking love coding because of solutions and explainations like this. god tier work.

  • @VY-zt3ph
    @VY-zt3ph 2 ปีที่แล้ว +5

    Until 12:00 I understood the actual neighbor's part. But after that things were not getting clear. It felt like you skipped something

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

    Hah, had to watch this 4 times to understand the intuition behind the solution. One of the toughest problem I have seen till date

  • @avaneeshponna831
    @avaneeshponna831 2 หลายเดือนก่อน

    Understood!! The problem is very similar to MCM question where we assume we are multiplying the selected matrix index at the last and calling 2 recursive functions to solve left and right sub-problems.

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

    Didn't understand the if(i>j) continue; statement

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

    In the tabulation approach, in the second for loop, we can run j from i to n.

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

    understood it but this was the tough one. To come up with the right approach for such questions is the most difficult part.

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

    Read many solution where they just told that it's MCM add 1s to start and end that's it, but I didn't find it intuitive...
    This solution is logical rather than mugging up those solution!

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

    Really a great, clean, clear and concise solution.

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

    Understood Bro , Thanx for the wonderful explanation 👍

  • @mriduljain6809
    @mriduljain6809 2 ปีที่แล้ว

    Understood bhaiya!!
    Just a small enhancement, we do not need to check the condition (i>j) , we can start j from i, and the code will work fine.
    int maxCoins(vector& nums) {
    nums.insert(nums.begin(),1);
    nums.push_back(1);
    int n=nums.size();
    vector dp(n,vector (n,0));
    for(int i=n-2;i>=1;i--)
    {
    for(int j=i;j

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

    Wow-what an awesome explanation sir. Thanks for all the hard work that you put in, in making these videos.

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

    Bro ,u can use backtracking like keep bool array for bursted balloons ,and then calculate from top to down itself

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

      Yes, you can, but you cannot apply Memoization to it!

  • @AbhishekYadav-rm4hw
    @AbhishekYadav-rm4hw ปีที่แล้ว +3

    THIS PROBLEM IS JUST AN MCM problem. I find this explanation a bit complicated than that approach.
    You just need to add 1 at the beginning and at the end, then just copy paste the same MCM code with the condition changed from finding min to max and that will work.
    I think you can see why, if anyone is facing issue let me know here, I'll explain.

    • @Priyasingh-xr6df
      @Priyasingh-xr6df ปีที่แล้ว

      how it is working, can you share your code?

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

    best question and explanation in my coding journey

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

    You don't know but you will gave india a top notch quality engineers even the 12th students have started DSA 😅

  • @neelulalchandani7429
    @neelulalchandani7429 4 หลายเดือนก่อน

    amazing explanation to an amazing problem, thankyou. Understood!

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

    if in any interview a guy faces this type of questions for the first and able to come up with a solution at that point because the previous video has helped with the fact that why serial wise approach wouldnot help but thinking of the backward approach is tough

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

    Understood! Aaaaaaaamazing as always, thank you very much!!

  • @paneercheeseparatha
    @paneercheeseparatha 4 หลายเดือนก่อน

    Thanks was struggling with the problem a lot. But atleast did the tabulation myself.

  • @kamleshverma-s2w
    @kamleshverma-s2w 8 หลายเดือนก่อน +2

    i did not understand if u are considering it the last one then why didn't you multiply with 1 instead of neighbours????

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

    Hi striver. First of all thanks for the explanation. I understood the explanation but when i looked at the code it is exactly similar to other problems we did[say l49 or l50] which were done in a top down approach. So i don't understand how the code is the same for which ever approach we take. If i looked at the code directly without looking at your explanation, i would think we are solving this problem exactly as we did for mcm or break stick problem which should not be the case as the approaches for the problems are totally different. Please help me understand this part. Thank you!

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

    If you dont want to modify the input array.
    class Solution {
    public int maxCoins(int[] nums) {
    return helper(nums, 0, nums.length - 1);
    }
    public int helper(int[] nums, int i, int j)
    {
    if(i > j)
    return 0;

    int max = Integer.MIN_VALUE;
    for(int k = i; k

    • @VinayKumar-xs6el
      @VinayKumar-xs6el 4 หลายเดือนก่อน

      thanks wt is difference btn last problem & this problem both codes looks same. last one sorted this one no need to sort

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

    kirti purswani wala burst balloon bahut acha hai. wo bhi dekhna kabhi

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

    Thankyou so much for amazing explanation Striver

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

    Thank you so much Striver, Understood.

  • @prabhakaran5542
    @prabhakaran5542 7 หลายเดือนก่อน +2

    Understood ❤❤❤❤❤❤

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

    Partition Array for Maximum Sum 1
    Palindrome Partitioning II
    Scramble String
    Burst Balloons 2

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

    Bhaiya in Tabulation in the second nested loop why are we starting from j=1 and not j=i+1??? our j will always be on the right side of i isn't it? (just like in the last examples of partition dp)

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

      Yes, u can, i just wrote a genric way, and then used the if statement inside

  • @ntgrn-pr5yx
    @ntgrn-pr5yx 2 หลายเดือนก่อน

    THANK YOU SO MUCH STRIVER

  • @vatsalyaa.m
    @vatsalyaa.m 9 หลายเดือนก่อน

    i have a thought ... can we place a barrier between any 2 balloons like 1... {1,b1,1,b2,1,b3,1,b4,1,b5,1,b6,1}... so that every subproblem becomes independent? and we can calc the cost by moving 2 steps back and forth instead of 1... correct me if i am wrong...

  • @arinmahapatro61
    @arinmahapatro61 8 หลายเดือนก่อน

    GOATed explanation!

  • @AlokSingh-jw8fr
    @AlokSingh-jw8fr 2 ปีที่แล้ว +4

    "Minimum Cost to Merge Stones" Bhaiya please add this problem in your dp series . It's a humble request .
    I have gone through a lot of solution in leetcode discuss forum but nobody has explained the intuition . This problem was asked in agoda online coding round. It's a pretty important as well as the hardest dp problem i have ever encountered.

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

    23:24 that's a mistake it should be max

  • @bhushankorg5606
    @bhushankorg5606 2 ปีที่แล้ว

    Understood clearly need watch it 2 times

  • @abhisheksinghdangi5027
    @abhisheksinghdangi5027 4 หลายเดือนก่อน +2

    bhai ka ek video smjhne m meri video.length*2 ka time lg rha h.......

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

    Hey!!
    Striver, I have a question, please. Or anyone who might help. You said we can't burst a balloon from the original array directly because that will make it have dependencies on the next element after b4 bursts. Now, what if, we burst b4, remove it out of the array, then add 1 in its place? Also we will add 1 in the next array's 0th index. Would that work?
    a = [b1 b2 b3 b4 b5] (b3 BURST )-----------> vector A = 0-> ind-1 A3 BURST A.add(1); A.insert(A.begin(),1);
    vector B = ind+1 -> n B.add(1); B.insert(B.begin(),1);
    cost = f(1,A.size()-1) * a[ind] * f(1,B.size()-1);
    P.S.: I haven't tried this code. It is a question of why won't this work? Please if anyone knows, may you help me out?!
    AND THANK YOUUU STRIVER FOR THE AMAZING VIDEOSS!!!!!!

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

    US striver , Difficult one to think , If i was asked this , I would ask for a diff problem

  • @CODEWITHEASE-u8l
    @CODEWITHEASE-u8l 3 หลายเดือนก่อน

    i want to ask that in approach raj bhaiya said that we have to move from down to solve it but in solution it moves from top how?

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

    Can you please explain how to know that a question requires a partial DP approach?

    • @aryansinha1818
      @aryansinha1818 2 ปีที่แล้ว

      Good question. Did you find the answer?

    • @ahanavishwakarma3956
      @ahanavishwakarma3956 2 ปีที่แล้ว

      @@aryansinha1818 no

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

      THe questions that have to be solved in a particular way are usally solved using partition dp.
      These questions may have different answer depending on the way we solve eg maths equation with bracket and without bracket,MCM etc
      multiple way to solve and have to find the best way to solve.

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

      @@aryansinha1818 THe questions that have to be solved in a particular way are usally solved using partition dp.
      These questions may have different answer depending on the way we solve eg maths equation with bracket and without bracket,MCM etc
      multiple way to solve and have to find the best way to solve.

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

    Hi Bro , you are mega star ⭐️ in creating this kind of tech content in YT ,love you lots 🙏

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

    On 14:0 what means by 1,5 is the range??

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

    Amazing explanation striver bhaiya!!! Thank you so much for such a wonderful content

  • @gurmeharsingh7251
    @gurmeharsingh7251 8 หลายเดือนก่อน

    simply the best !

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

    hey striver my recursive code is giving stackoverflow, cant handle it.
    Please help

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

    As always "understood" ❤️

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

    better explanation that than neetcode guy

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

    hey striver..!!
    can you explain boolean parenthesization probblem

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

    Can anybody tell why we are sorting the array in Min cost to cut stick and not in this?
    And how to know when should we sort the array and when to not??

  • @dhruvbajaj5079
    @dhruvbajaj5079 2 ปีที่แล้ว

    This is the best explanation out there.

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

    Not understanding dp partition problems.

  • @sameersahu4569
    @sameersahu4569 2 ปีที่แล้ว

    Thank you Striver!!Understood

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

    Hey I solved it on my own ❤ Thankyou

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

    Understood, sir. Thank you very much.

  • @chase.2595
    @chase.2595 ปีที่แล้ว

    did it on my own :)) similar approach to dp 50

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

    i just want to know how exactly can we identify that a question is of partition type or not

  • @NikhilGupta-zo5jh
    @NikhilGupta-zo5jh 2 ปีที่แล้ว +1

    Damn this is extremely awesome!!!

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

    Striver please...can you explanation of Merging Stones (leetcode hard) problem...I searched many yt channel but still confused...please help

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

    Understood !! that I haven't understood 🙃🙃

  • @shivamshrey47
    @shivamshrey47 2 ปีที่แล้ว

    The Python3 versions of the solutions exceed the time limit (TLE) on LeetCode.

  • @saunaknandi1814
    @saunaknandi1814 2 ปีที่แล้ว

    In ur insta post u mentioned it will be the biggest DP series, how many videos left

  • @VikashYadav-px8ei
    @VikashYadav-px8ei ปีที่แล้ว +1

    Understood 🎉

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

    Understood :)
    Hard question, beautifully explained!!
    Aug'3,2023 04:14 pm

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

    Such a unique approach

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

    so great video, thanks

  • @nikhil6842
    @nikhil6842 2 ปีที่แล้ว

    Definitely understood, great explaination

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

    I don't think its very possible to come up with this kind of a solution if one hasn't solved it earlier

  • @ShubhamKumar-fn5be
    @ShubhamKumar-fn5be ปีที่แล้ว

    Understood BTW its just similar to cut the stick problem😂😂

  • @user-du6et6ek4n
    @user-du6et6ek4n 3 หลายเดือนก่อน

    can anyone explain in tabulation by n + 2 , if index + 1 goes till j then j + 1 is already there

  • @UECAshutoshKumar
    @UECAshutoshKumar 7 หลายเดือนก่อน

    Thank you!
    Understood!

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

    Understood🔥

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

    class Solution {
    public:
    //Very minor changes to 1547. Minimum Cost to Cut a Stick Problem
    // Which baloon should I burst first? -------> WRONG APPROACH -----> dependant subproblems
    // Let this baloon be the last baloon to be burst ----> CORRECT
    int func(int left,int right,vector& cuts,vector& rod,vector& dp)
    {
    if(left>right) return 0;
    if(dp[left][right]!=-1) return dp[left][right];
    int ans=INT_MIN; //CHANGE
    for(int cutatindex=left;cutatindex

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

    Non intuitive not a single thought came to solve it like this even after knowing that it requires MCM 😭😭 .
    had to watch video for solution

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

    Understood, thanks.

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

    problem link is for different problem

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

    Great Explanation Striver

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

    Thanks for the good explanation for Memoization. But tabulation explanation was poor. Please explain state in dp. What does dp[i][j] store? We require intuition for tabulation and not shortcuts.

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

      The intuition comes from recursion, whatever i and j were in recursion, its the same in iteration as well, Since you memoize dp[i][j], you must be knowing what it means when you memoizing, its the same in iterative.
      I am sorry, but people who tend to look for everything fetched on their plate end nowhere. Good luck, apply brains, everything is there in the lecture.

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

      @@takeUforward I got it now. Thanks. I too think that I have got a bad habit of looking for everything served on my plate. Starting to correct it.

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

    Mast hai sir aapka explanation, maja aa gya😀

  • @ayaanrashid960
    @ayaanrashid960 3 หลายเดือนก่อน

    this is the hardest question among all I've encountered.

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

    Amazing explanation !!