DP 48. Matrix Chain Multiplication | MCM | Partition DP Starts 🔥

Поділитися
Вставка
  • Опубліковано 30 вер 2024
  • Lecture Notes/C++/Java Codes: takeuforward.o...
    Problem Link: bit.ly/3nXqfce
    Pre-req for this Series: • Re 1. Introduction to ...
    a
    Make sure to join our telegram group for discussions: linktr.ee/take...
    Full Playlist: • Striver's Dynamic Prog...
    In this video, we solve the MCM Dp, this is the first problem on the pattern Partition DP.
    If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.o...
    You can also get in touch with me at my social handles: linktr.ee/take...

КОМЕНТАРІ • 493

  • @aayushisaha8
    @aayushisaha8 2 роки тому +139

    👏👏👏 To everyone who made it this far !! And Double 👏👏 for those who didn't 💤 during this video . Cause it's a reallly long video ( ig mini movie 😅) . And just thinking of how much effort Striver bhaiya must have gone though to make it , edditing it , correcting it 👏👏 , Frankly speaking of me I dozed off 😪 a couple of times during the entire video 🤪 . But anyways Great Work , Striver bhaiya ✌

    • @momozkichutney
      @momozkichutney 2 роки тому +63

      arey aaram se bolo didi, ye beech beech mei daure pad rhe h kya!

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

      @@momozkichutney 🤣🤣🤣🤣

    • @AshokKumar-ii4qr
      @AshokKumar-ii4qr Рік тому +9

      @@momozkichutney wo stree h k6 v kr skti h 😂😂

    • @anshumann
      @anshumann 7 місяців тому +2

      Lgta hai didi zyda moody hai bich bich itna mood swings 😂

    • @theexplorer9012
      @theexplorer9012 3 місяці тому

      ye kya bawasir likh diya be

  • @trex4997
    @trex4997 8 місяців тому +59

    Bhaiya u r God sent angel. God heard the upcoming SDE's cry the whole nights, and then planted the idea of making DSA playlists in your head.
    Bowing to your intellect, dedication and hardwork .

  • @sakshigupta4793
    @sakshigupta4793 2 роки тому +17

    TBH for dp series Aditya Verma & you are the best. 😊

  • @PankajYadav-zg1re
    @PankajYadav-zg1re 2 роки тому +81

    Finally I got the exact idea how the recursion works in MCM problem , before your vdo I have watched a lot but didn't get clear idea ......You are awesome bhaiya ❤️❤️❤️❤️

    • @ayushjain386
      @ayushjain386 2 роки тому +2

      Can you help me i am not understand steps= a[i-1]*a[k]*a[j]+func(i,k)+func(k+1,j)
      Why are again call function func (i,k)+func(k+1,j) again

    • @sanketmudholkar2889
      @sanketmudholkar2889 2 роки тому +2

      @@ayushjain386 Because we have to compute the smaller part also like if we have (ab) and (cd) so we have to solve ab and cd seperately also .

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

      @@ayushjain386 bro,suppose (AB)(CD) hai to finally AB * CD krne ka cost aaya hoga but (A*B) apne aap me bhi ek ques h n isko multiply krne me bhi cost aaya hoga to usko nikalne ke liye func(i,k) use kiya hai. Similarly, (C*D) ko bhi krna hoga jo ki other left over part hai partition ke baad to usko func(k+1,j) likha....! Thoda pen chalao or video waps dekho aajayega

  • @gyanunlimited740
    @gyanunlimited740 2 роки тому +71

    Its been 6 years since I came across this topic and finally understood it today

    • @trijalsharma4471
      @trijalsharma4471 Рік тому +20

      you've been unemployed for quite some time 😆

    • @codingalley6229
      @codingalley6229 2 місяці тому +4

      @@trijalsharma4471 solving a damn specific problem doesn't mean you are smart buddy.

  • @anmolagarwal5950
    @anmolagarwal5950 Рік тому +14

    That's the best video ever on Partition DP 👏 so much effort goes into making such content for generations, hats off man 👏👏

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

    Understood
    ------------------------------
    Recursion :-
    TC---> exponential
    Memoisation:-
    TC---> O(N*N*N)
    SC--->O(N*N) + O(N)

  • @ganeshkamath89
    @ganeshkamath89 2 роки тому +20

    Thanks Striver. Understood.
    6 months back I had tried to learn it but I found it difficult. With your explanation I think I will remember how to do MCM and partiton DP.

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

      I tried it multiple times earlier but now I got better understanding, indeed it will stuck in my mind now.

  • @tanishgotti3659
    @tanishgotti3659 21 день тому +1

    You didn't explain why you cant think in terms of the entire array.

  • @coding8000
    @coding8000 Рік тому +1

    Understoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooood

  • @raghavmanish24
    @raghavmanish24 Місяць тому +1

    MJHE BELEIVE NHH THA PHLE KI MAI YE TOPIC SMJH LUNGA EK BAAR ME .....BUT STRIVER MAKE IT EASY ......#UNDERSTOOD

  • @rohan8758
    @rohan8758 Місяць тому +1

    Understood, I am feeling very sleepy, time is 2:11 AM but this video motivate me to watch it till i understand it completely, lot of Thanks @Striver for your DP Series!!!!

  • @shivanssingh4897
    @shivanssingh4897 2 роки тому +6

    Hi Striver, can you explain problems on pattern dp like burst baloons etc. Your explaination is very good btw.

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

    Us

  • @AbhishekYadav-rm4hw
    @AbhishekYadav-rm4hw Рік тому +1

    shouldn't the base case be if(j==i || j==i+1) return 0; as when j = i+1 then also there is only one matrix which is possible and then also we can't multiply.
    Edit: I appologize, I got it now

  • @rishavsaha5254
    @rishavsaha5254 2 роки тому +8

    Understood. Before starting this topic, I had 0 knowledge about this topic, now after completing this video, I am taking the complete concept. Thank you so much for coming up with this amazing DP series striver.

  • @siding6690
    @siding6690 9 місяців тому +1

    #include
    int solve(int* arr, int i, int j){
    if(i == j) return 0;
    int mini = 1e9;
    for(int k = i; k

  • @stith_pragya
    @stith_pragya 8 місяців тому +2

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

  • @ronakslibrary8635
    @ronakslibrary8635 Рік тому +1

    Understood , difficult concept explained easily🤯🤯

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

    understood that is not a question this a concept ....
    hats off to your efforts man you are just amazing

  • @mohitagarwal3639
    @mohitagarwal3639 2 роки тому +10

    Hey Striver again thanks to you for teaching in such a wonderful way.
    I paused the video at 25:30 after understanding the approach to the problem and was able to solve upto memoization by myself.
    Thanks man keep up the good work.

  • @sameersahu4569
    @sameersahu4569 2 роки тому +12

    What an explanation....Partition was a concept i was not much clear with .....
    Thank you for making me understand this concept

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

    I'm blind...how am I supposed to watch this insightful lecture 🥺

  • @madhuryareddy3994
    @madhuryareddy3994 6 місяців тому +1

    Thanks for existing man, you don't know how thankful I am🙏🙏you made this explanation such that I can never forget this concept in my life.

  • @vivekpaliwal1876
    @vivekpaliwal1876 Рік тому +1

    I like your vedios...your way of teaching is good...but 1 thing you can add at start of vedios that which application uses this algorithm just to increase interest in learning the algo...

  • @UECAshutoshKumar
    @UECAshutoshKumar 3 місяці тому +1

    Thank You
    Understood!!!

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

    Best Ever Explanation for MCM. Literally!

  • @Noob_Coder1234
    @Noob_Coder1234 7 місяців тому +1

    HATS OFF TO THE GOAT STRIVER , HE HAD PUT LOT OF EFFORTS FOR US IN THIS VIDEO SO WE CAN UNDERSTAND THIS TOUGH TOPIC , REALLY AMAZING❤❤

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

    Awesome Just amazing lecture😃

  • @dhikshithgoshika2700
    @dhikshithgoshika2700 2 роки тому +10

    wah wah got the depth of deep recursion took me 2 days to completely write the total recursive code and understand .really striver bayya if you and your videos are not there many of us would leave hopes for preparing other companies , may god give you all the health and wealth bayya 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

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

    Understood Sir, Thank you very much

  • @UCSDebajyotiDas
    @UCSDebajyotiDas Рік тому +1

    The code studio question is little bit changed now f(1,n,arr) will work instead of n-1

  • @madhavdwivedi5146
    @madhavdwivedi5146 Рік тому +1

    kya mast padhaya hai.....aapko dekhke mera khud padhane ka man hogya...❣❣❣❣❣❣

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

    Thanks a lot for such a wonderful explanation sir :)

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

      The Great Rohit Negi is here!

  • @leonardescharlson879
    @leonardescharlson879 25 днів тому

    Rodriguez Kimberly Thomas Melissa Clark Ruth

  • @kaushalshinde3920
    @kaushalshinde3920 Рік тому +1

    Understood!!

  • @sathwikabhignan1862
    @sathwikabhignan1862 3 місяці тому +1

    my goodness!! crystal clear explanation I am grateful for your dp series, thank you, Striver.

  • @googleit2490
    @googleit2490 10 місяців тому

    DP Revision:
    Forgot the concept so had to rewatch the whole video ;-;
    Nov'20,2023 06:11 pm

  • @Pankajsingh-ej8qk
    @Pankajsingh-ej8qk 2 роки тому +1

    how to solve the same problem starting from i = 0 , like in this question you have done with i = 1

  • @VinayKumar-ze2ww
    @VinayKumar-ze2ww 2 роки тому +3

    Another great video, thanks striver for making me understand MCM
    50 minute sound huge but it just flew by

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

    areeee bhaiyaaa omphooo!!! zammmn bhai understood....saying this video is god damn amazing is an understatement.

  • @fanofabdevillersandmathslo5960
    @fanofabdevillersandmathslo5960 29 днів тому +1

    Understood

  • @aftabalam7103
    @aftabalam7103 2 роки тому +2

    Very clear and solid explanation,Thanks buddy

  • @prabhakaran5542
    @prabhakaran5542 4 місяці тому +1

    Understood ❤❤❤

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

    Really nice explanation srtiver. I like the way that you teach and understood the MCM.Very tricky but now understood.

  • @animeshkumar2683
    @animeshkumar2683 Місяць тому +1

    Understood

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

    understood 👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍

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

    after watching this video. New Courage Unlocked!

  • @DtscjjDtedh
    @DtscjjDtedh 25 днів тому

    Moore Mark Hernandez Joseph Smith Dorothy

  • @bhavanisankarlenka
    @bhavanisankarlenka 4 місяці тому +1

    understood

  • @shrshawn
    @shrshawn 4 місяці тому

    if u can spare 1 hr, this video will fully make u understand the problem

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

    How did you decide in tabulation
    i from n-1 to 0 and
    J= i+1 to n-1
    Why j is not from n-1 to i or
    i from 1 to n-1

  • @srinathv1412
    @srinathv1412 8 місяців тому +1

    Understoos!

  • @JohnSnow-r1e
    @JohnSnow-r1e 2 місяці тому

    Give this guy 10M subscriber by the end of the 2024

  • @arnabroy2995
    @arnabroy2995 Рік тому +1

    US❤ awesome explanation ❤

  • @ritwik121
    @ritwik121 2 роки тому +7

    @striver Great explanation ... hope you will making a video on burst ballons and how to think for that problem ...

  • @tle964
    @tle964 9 місяців тому +1

    understood

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

    Thanks a lot man plz donot stop ur series today there might be very less reach imagine after 6 months u will get shocked by reach just plz donot stop posting vedios

  • @akashpal7748
    @akashpal7748 Рік тому +1

    understood

  • @udatyadeb101
    @udatyadeb101 Рік тому +1

    understood

  • @108_adityakumar6
    @108_adityakumar6 2 роки тому +2

    Understood.🔥🔥Your dp series is best.

  • @mdshaheer181
    @mdshaheer181 Рік тому +1

    understood

  • @deathigniter2155
    @deathigniter2155 3 місяці тому

    why doesnt this work? can anyone tell me? its not passing any testcase!!
    ll solve(ll i , ll j , ll arr[] , vector < vector < ll > > &dp){
    if(i == j) return 0;
    if(dp[i][j] != 2e9) return dp[i][j];
    for(int k = i; k < j; k++){
    return dp[i][j] = min(dp[i][j] , solve(i , k , arr , dp) + solve(k + 1 , j , arr , dp) + (arr[i - 1] * arr[k] * arr[j]));
    }
    }
    ll matrixMultiplication(ll n, ll arr[])
    {
    vector < vector < ll > > dp(n + 1 , vector < ll > (n + 1 , 2e9));
    return solve(1 , n - 1 , arr , dp);
    }

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

    please start new channel in hindi
    learning dsa in hindi in another level of experience

  • @kartikhatwar7374
    @kartikhatwar7374 Рік тому +1

    UnderStood

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

    Understood

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

    Super Clear Understood.

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

    Plz plz plz dp on graphs asap love ur work 🙏❤️

  • @sauravchandra10
    @sauravchandra10 Рік тому +1

    Clearly understood, thanks!

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

    Thank you Sir ! Understood.

  • @cminor9037
    @cminor9037 Рік тому +1

    "US"

  • @CHANDANKUMAR-sg8cp
    @CHANDANKUMAR-sg8cp Рік тому +1

    #understood

  • @MAYANKKUMAR-dh9eh
    @MAYANKKUMAR-dh9eh Рік тому

    I had seen the video twice only then i understood the video well
    in between the video I am getting very angry it is getting harder and harder to understand

  • @juniorboy1903
    @juniorboy1903 2 роки тому +2

    It's hard but u have made it very easy to understand thanks bhaiya 😃😍

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

    Nice explanation striver🔥🔥

  • @gauravbanerjee2898
    @gauravbanerjee2898 3 місяці тому

    Thank you so much striver ❤❤

  • @adarsh_k_agrawal
    @adarsh_k_agrawal 4 місяці тому

    Understood LIS Pattern completely. Watching all the videos from the start of DP. It is really really helpful. Every concepts are clear and will surely finish the playlist. Thank you Striver, emiti amazing content pai.

  • @asit7456
    @asit7456 Рік тому +1

    The notes for MCM DP are incomplete please sir do complete it as notes are very much helpful for revision.

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

      where are the notes uploaded for DP series?

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

    umm auxiliary stack space distracted me a bit XD

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

    Understood completely!

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

    Which application are you using to write on?

  • @sanaaroraa9315
    @sanaaroraa9315 3 місяці тому

    Amazing! understood

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

    bhaiya bahut accha samjhaya....thanks a lot

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

    sir what will be the exact TC of the recursive approach without memoization.

    • @takeUforward
      @takeUforward  Рік тому +1

      You cannot say exact TC of recursion, because it is generically exponenitation in nature as it tries all ways.

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

    what arr[st-1]*arr[k]*arr[end] tells if any body understood please tell in comment

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

      31:02 you can understand

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

      what is the answer of your current range(st,end) arr[st-1]*arr[k]*arr[end]
      what is the answer in left part
      what is the answer in right part

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

      @@upsolvecontest4677 it states the operations required to multiply the left part and the right part, once they have been individually solved

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

    Bhai ek hi chiz ko kitne bae repeat kra h...faltu ka vidoe itna bada kr dia

  • @michael-pasquale
    @michael-pasquale 2 роки тому +2

    Understood. Excellent explanation!

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

    Understood. Helped a lot !

  • @CoderSlot
    @CoderSlot 8 місяців тому

    Hey striver ,i just come across to check your memorization code available at article of the same problem in dsa list and found that their is an error in your code as although you are checking for availability of precomputed (i,j) in dp by this : if(dp[i][j]!=-1)
    but you forget to update it at the end with the value you are returning i.e.
    return dp[i][j]= mini;

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

    bhaiya tabulation khud se likh diya 😄

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

    AMAZING EXPLANAITION AS USUAL!

  • @ShubhamVerma-hk9qt
    @ShubhamVerma-hk9qt Рік тому

    thanks striver Understood!!!!

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

    thankyou bro, very clear and easy explaination .

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

    Best video I have ever seen on dp🔥

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

    Please tell me how do i apply formula arr[i-1]+arr[k]+arr[j] on BCD recursive call because i is set to 0 index on BCD call
    I found the solution which is that actually the whole array is passed in all the recursive call only pointer are moving that is i and j so there will always a arr[i-1] present in all the calls thats all.

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

    understood the concept !!

  • @gentleman7060
    @gentleman7060 Рік тому +1

    All of your dp problems should have one playlist. It would be helpful.

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

    Understood! Hats off🙏

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

    Thank you so much bhayya ;)

  • @bakyt_yrysov
    @bakyt_yrysov Рік тому +1

    Thank you soo much!! Please, keep posting such this amazing content!