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

Sdílet
Vložit
  • čas přidán 21. 04. 2022
  • Lecture Notes/C++/Java Codes: takeuforward.org/dynamic-prog...
    Problem Link: bit.ly/3Kgck9N
    Please watch the video at 1.25x for a better experience.
    Pre-req for this Series: • Re 1. Introduction to ...
    a
    Make sure to join our telegram group for discussions: linktr.ee/takeUforward
    Full Playlist: • Striver's Dynamic Prog...
    In this video, we solve the burst balloons problem which is a part of partition DP.
    If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.org/interviews/s...
    You can also get in touch with me at my social handles: linktr.ee/takeUforward

Komentáře • 310

  • @gopeshkhandelwal9823
    @gopeshkhandelwal9823 Před 2 lety +308

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

    • @abh9789
      @abh9789 Před 2 lety +10

      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 Před 2 lety +34

      @@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 Před 2 lety +3

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

    • @gopeshkhandelwal9823
      @gopeshkhandelwal9823 Před 2 lety +12

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

    • @VY-zt3ph
      @VY-zt3ph Před 2 lety +30

      You proved that we don't need scaler.

  • @spandanrastogi7144
    @spandanrastogi7144 Před rokem +90

    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 Před 2 lety +122

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

    • @k.chetankumar6533
      @k.chetankumar6533 Před rokem

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

    • @rocklee3254
      @rocklee3254 Před rokem +8

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

    • @balakrishnanr648
      @balakrishnanr648 Před rokem +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)

  • @Harshit126
    @Harshit126 Před rokem +62

    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!

  • @girishbhargava6367
    @girishbhargava6367 Před rokem +27

    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.

  • @bluesteel1
    @bluesteel1 Před 5 měsíci +2

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

  • @Dontpushyour_luck
    @Dontpushyour_luck Před rokem +9

    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 Před 11 měsíci

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

  • @vinayakbajpeyi931
    @vinayakbajpeyi931 Před rokem +3

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

  • @nilimsankarbora5911
    @nilimsankarbora5911 Před 7 měsíci +2

    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. ❤❤❤

  • @chandrachurmukherjeejucse5816

    Really a great, clean, clear and concise solution.

  • @shantanudev8576
    @shantanudev8576 Před 2 lety +2

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

  • @rohitraj5832
    @rohitraj5832 Před 2 lety +8

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

  • @shlok1124
    @shlok1124 Před rokem +10

    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.

  • @cinime
    @cinime Před 2 lety +1

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

  • @stith_pragya
    @stith_pragya Před 6 měsíci +1

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

  • @DevashishJose
    @DevashishJose Před 6 měsíci

    Thank you so much Striver, Understood.

  • @samyakjain7422
    @samyakjain7422 Před 2 lety +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 Před 2 lety +13

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

  • @ritikshandilya7075
    @ritikshandilya7075 Před 18 dny

    Thankyou so much for amazing explanation Striver

  • @berserker556
    @berserker556 Před měsícem +1

    Understood Bro , Thanx for the wonderful explanation 👍

  • @scripter7676
    @scripter7676 Před rokem +8

    i am now in codenation just because of you striver

  • @arinmahapatro61
    @arinmahapatro61 Před 2 měsíci

    GOATed explanation!

  • @GungunRamchandani
    @GungunRamchandani Před měsícem

    Understood, thanks.

  • @gurmeharsingh7251
    @gurmeharsingh7251 Před 2 měsíci

    simply the best !

  • @Pritesh-sh21
    @Pritesh-sh21 Před 2 lety +8

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

  • @UECAshutoshKumar
    @UECAshutoshKumar Před měsícem

    Thank you!
    Understood!

  • @prabhakaran5542
    @prabhakaran5542 Před měsícem +2

    Understood ❤❤❤❤❤❤

  • @shubhampol9
    @shubhampol9 Před rokem +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 Před měsícem +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!

  • @Hrushi_2000
    @Hrushi_2000 Před 10 měsíci

    Thankyou sir. Understood.

  • @rimpiranibaruah7922
    @rimpiranibaruah7922 Před rokem +1

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

  • @karthikeyan1996_
    @karthikeyan1996_ Před rokem +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

  • @adarshdubey1784
    @adarshdubey1784 Před 2 lety +3

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

  • @ravivarmachaluvadi9158
    @ravivarmachaluvadi9158 Před 2 lety +2

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

  • @sameersahu4569
    @sameersahu4569 Před 2 lety

    Thank you Striver!!Understood

  • @nikhil6842
    @nikhil6842 Před rokem

    Definitely understood, great explaination

  • @jaishriharivishnu
    @jaishriharivishnu Před 22 dny

    Nice one !!!

  • @BeingEntertained
    @BeingEntertained Před 2 lety +2

    best question and explanation in my coding journey

  • @1tav0
    @1tav0 Před rokem

    understood!!! thank you so much sir

  • @nanduriamrutha1552
    @nanduriamrutha1552 Před 8 měsíci +1

    thank you !!

  • @ratinderpalsingh5909
    @ratinderpalsingh5909 Před rokem

    Understood, sir. Thank you very much.

  • @dhruvbajaj5079
    @dhruvbajaj5079 Před rokem

    This is the best explanation out there.

  • @bhushankorg5606
    @bhushankorg5606 Před rokem

    Understood clearly need watch it 2 times

  • @udayjordan4262
    @udayjordan4262 Před rokem +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

  • @mriduljain6809
    @mriduljain6809 Před rokem

    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

  • @rutujawaghmode5354
    @rutujawaghmode5354 Před rokem

    Hey I solved it on my own ❤ Thankyou

  • @arihantjammar8888
    @arihantjammar8888 Před 9 měsíci

    Understood 😊

  • @ujjalsaha428
    @ujjalsaha428 Před 2 lety +2

    As always "understood" ❤️

  • @harshkanani6605
    @harshkanani6605 Před rokem

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

  • @GhostVaibhav
    @GhostVaibhav Před 5 měsíci

    Understood🔥

  • @coolgaurav5163
    @coolgaurav5163 Před 3 dny

    UNDERSTOOD

  • @studynewthings1727
    @studynewthings1727 Před 3 měsíci +1

    understood

  • @ShashankRustagiCSE
    @ShashankRustagiCSE Před 2 lety +2

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

  • @HariSarvotama
    @HariSarvotama Před 2 lety +1

    Amazing explanation !!

  • @SWE_69
    @SWE_69 Před rokem

    thanks able to solve on my own.

  • @saurabhrthakur
    @saurabhrthakur Před 3 měsíci

    Understood

  • @brokegod5871
    @brokegod5871 Před 3 dny

    No need to insert 1 at the end and start, you can just check if i and j are at the boundary before calculating the product. This is the memoised code, you can surely do the tabulation by now
    class Solution {
    public:
    int solve(int i, int j, int n, vector &nums, vector &dp) {
    if(i>j) return 0;
    if(dp[i][j]!=-1) return dp[i][j];

    int ans = INT_MIN;
    for(int k=i;k= n) ? 1 : nums[j+1]; //if j+1 is out of bounds

    int coin = left*nums[k]*right + solve(i,k-1,n,nums, dp) + solve(k+1,j,n,nums,dp);
    ans = max(ans, coin);
    }

    return dp[i][j] = ans;
    }
    int maxCoins(vector& nums) {
    int n = nums.size();
    vector dp(n, vector (n, -1));
    return solve(0,n-1,n,nums,dp);
    }
    };

  • @bgmedits2515
    @bgmedits2515 Před 2 lety +8

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

    • @sypher4735
      @sypher4735 Před rokem +2

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

  • @NikhilGupta-zo5jh
    @NikhilGupta-zo5jh Před 2 lety +1

    Damn this is extremely awesome!!!

  • @chase.2595
    @chase.2595 Před 8 měsíci

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

  • @ganeshkamath89
    @ganeshkamath89 Před 2 lety

    Thanks Striver. Understood.

  • @VY-zt3ph
    @VY-zt3ph Před 2 lety +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

  • @abhimanyuraizada7713
    @abhimanyuraizada7713 Před 11 měsíci

    Such a unique approach

  • @googleit2490
    @googleit2490 Před rokem

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

  • @devanshtiwari9163
    @devanshtiwari9163 Před 7 měsíci

    Got it bro.

  • @kanwarsandhu5031
    @kanwarsandhu5031 Před 17 dny

    better explanation that than neetcode guy

  • @Parthj426
    @Parthj426 Před 13 dny

    Understood , #Chamka

  • @ramjivijayabaskar
    @ramjivijayabaskar Před 2 lety +1

    Great Explanation Striver

  • @rishabhagarwal8049
    @rishabhagarwal8049 Před rokem

    Understood Sir Thank u very much

  • @pratyakshhhhhhhhhhhhhhhhhhhhh

    Nicee

  • @coding8000
    @coding8000 Před 2 lety

    Understood, thank you bhaiya.

  • @aryanyadav3926
    @aryanyadav3926 Před 2 lety +1

    Brilliant!

  • @manojrana8649
    @manojrana8649 Před 2 lety

    U r amazing striver!!

  • @VY-zt3ph
    @VY-zt3ph Před 2 lety +3

    9:39 this is why you are here 😹😹😹

  • @pheonix26839
    @pheonix26839 Před 2 lety

    👍🏻🔥 thank you

  • @madhurjyasaha6798
    @madhurjyasaha6798 Před rokem

    the explanation is excellent

  • @saunaknandi1814
    @saunaknandi1814 Před 2 lety

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

  • @sanyamwalia217
    @sanyamwalia217 Před 11 měsíci

    Nice question... A head scratcher

  • @mohdkhaleeq7468
    @mohdkhaleeq7468 Před rokem

    yes understood bro great explanation

  • @kongzilla2897
    @kongzilla2897 Před 2 lety

    Perfect

  • @user-zc4mg1pi6w
    @user-zc4mg1pi6w Před 2 měsíci +2

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

  • @baibhavdatta573
    @baibhavdatta573 Před 2 lety +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  Před 2 lety +10

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

  • @VikashYadav-px8ei
    @VikashYadav-px8ei Před rokem +1

    Understood 🎉

  • @Mukesh-nx8tf
    @Mukesh-nx8tf Před 2 lety

    what app do you use to record screen and for white board?

  • @abhisheknag1929
    @abhisheknag1929 Před 5 měsíci

    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

  • @shivamshrey47
    @shivamshrey47 Před rokem

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

  • @gauravchoudhary6253
    @gauravchoudhary6253 Před 2 lety +4

    Hey Striver Bhaiya, I have a doubt:-
    Why can't we follow it as we should leave both the numbers on the extreme ends. and from the left numbers we should start bursting the number which is the smallest. then 2nd smallest then 3rd and so on till the last number in between the both the extreme numbers ends. And then from the number which are last two extreme burst any one one of them first and and left number 2nd.
    eg:- [ 4,6,8,5,3,2,1,9]
    If this is the set remove the two numbers at the extreme ends:- 4,9 [6,8,5,3,2,1]
    Then start bursting the smallest number in the left set:- so the first number will be '1' == 2*1*9=18 4,[6,8,5,3,2],9
    then '2'== 3*2*9=54 4,[6,8,5,3],9
    then '3'== 5*3*9=135 4,[6,8,5],9
    then '5'== 8*5*9=360 4,[6,8],9
    then '6'==6*8*9=432 4,[8],9
    then '8'==4*8*9=288 [4,9]
    then left are 2 numbers which are 4,9. Now burst any number first let say I burst '4'==1*4*9=36 [9]
    then '9'==1*9*1=9 [ ]
    Total Sum=1332 and it will be maximum.
    Why can't we code using this method??? I am a FIRST YEAR STUDENT.

  • @prajjwalsharma819
    @prajjwalsharma819 Před měsícem

    wow

  • @tikshavarshney213
    @tikshavarshney213 Před 2 lety

    Understood !

  • @srikarvinjamara2003
    @srikarvinjamara2003 Před 5 měsíci +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!

  • @satyampande684
    @satyampande684 Před 2 lety

    understood!!

  • @iamnoob7593
    @iamnoob7593 Před 6 měsíci +1

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

  • @mannumichel1925
    @mannumichel1925 Před rokem

    Mast hai sir aapka explanation, maja aa gya😀

  • @AbhishekYadav-rm4hw
    @AbhishekYadav-rm4hw Před 10 měsíci +2

    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.

  • @ujjawal_
    @ujjawal_ Před 2 lety +3

    Nice content 😊👍

  • @vedantkavi6180
    @vedantkavi6180 Před rokem

    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??

  • @imajt5
    @imajt5 Před rokem

    kya explain kiya hai bhai..amazing

  • @KunalTambe-oy6lb
    @KunalTambe-oy6lb Před rokem

    Understood!!!!

  • @pawandeepchor89
    @pawandeepchor89 Před rokem

    Top class video... ❤

  • @suhaanbhandary4009
    @suhaanbhandary4009 Před rokem

    Understood!!