Matrix Chain Multiplication Dynamic Programming

  Рет қаралды 46,301

Pepcoding

Pepcoding

Күн бұрын

Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, you will learn about Matrix Chain Multiplication problem using Dynamic Programming. In this question :
1. You are given an array(arr) of positive integers of length N which represents the dimensions of N-1 matrices such that the ith matrix is of dimension arr[i-1] x arr[i].
2. You have to find the minimum number of multiplications needed to multiply the given chain of matrices.
To attempt and submit this question, click here: www.pepcoding....
For a better experience and more exercises, VISIT: www.pepcoding....
Have a look at our result: www.pepcoding....
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education

Пікірлер: 98
@ashwinvarma9349
@ashwinvarma9349 3 жыл бұрын
I always prefer your videos over others' for the depth you cover. Great explanation sir once again!!
@Pepcoding
@Pepcoding 3 жыл бұрын
Awesome, thank you!
@chandrakantshinde6
@chandrakantshinde6 3 жыл бұрын
perquisite for this problem is Palindrome partitioning problem and for Palindrome partitioning problem prereq. is Rod cutting problem, this series itself DP 😂😂🔥🔥, depend upon previous state
@mickyman753
@mickyman753 3 жыл бұрын
that palindrome partitioning also needs count of palindromic substring for that gap strategy matrix matrix too
@karanveersingh5535
@karanveersingh5535 2 жыл бұрын
😂
@abhilashpatel6852
@abhilashpatel6852 Жыл бұрын
This video itself is prerequisite for ballon burst problem 😂.
@harshshukla7260
@harshshukla7260 3 жыл бұрын
Thank you very much Sir. Best explanation. Bahut acha padhaate hai aap. You value your viewers.
@Pepcoding
@Pepcoding 3 жыл бұрын
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem. If you like our efforts, we request a review - g.page/Pepcoding/review?rc
@yashCeo
@yashCeo 3 жыл бұрын
The explanation was great as always sir. I would recommend including a recursive approach too in the video. If in an interview we directly give DP solution the interviewer might think ki ratt liya hai bande ne.
@shubhamagarwal2998
@shubhamagarwal2998 3 жыл бұрын
then why he is asking a easily available question...xd... practice nahi karein kya......
@theuntoldtree
@theuntoldtree 3 жыл бұрын
These r trivial questions , hardly any interviewer ll ask
@decostarkumar2562
@decostarkumar2562 2 жыл бұрын
@@theuntoldtree Really 🤔
@theuntoldtree
@theuntoldtree 2 жыл бұрын
@@decostarkumar2562 yeah,same to nhi puchhega
@deeptimittal05
@deeptimittal05 2 жыл бұрын
@@theuntoldtree hello vro, good to see you here😂^_^
@devkumar9889
@devkumar9889 2 жыл бұрын
This series is underrated
@asthagupta3813
@asthagupta3813 3 жыл бұрын
Gap strategy kaha par milegi
@rakshitdevra7060
@rakshitdevra7060 2 жыл бұрын
Hats off sir for such dedication towards teaching.
@DivyaPrakash-bj6zk
@DivyaPrakash-bj6zk 2 жыл бұрын
Sir bhut maza aa gaya . Awesome .
@aritralahiri8321
@aritralahiri8321 3 жыл бұрын
Wonderful explanation once again . Love the way you go in the very depth of every problem . Thanks a lot Sir !
@karthikrashinkar204
@karthikrashinkar204 2 жыл бұрын
please rearrange the playlist properly sir, I don't know where gap strategy is explained. Im watching video according to playlist. 🙏🏾🙏🏾🙏🏾🙏🏾
@codelikepro1088
@codelikepro1088 2 жыл бұрын
yes sir, please
@ashutak
@ashutak 3 жыл бұрын
How did you decide you are going to use Gap Strategy, could you please also explain, where this one becomes different from Longest common subsequence, or how many other ways will be there to solve this problem.
@gouravgoel2974
@gouravgoel2974 3 жыл бұрын
yes please sumit sir
@jatinlodhi980
@jatinlodhi980 2 жыл бұрын
Where you see problem is kind of sub arrays like ab BC ABC bcd. Because the complete abcde is forming from all that sub parts which is present in gap strategy matrix.
@ankushmilan6167
@ankushmilan6167 2 жыл бұрын
Can someone please tell me what is the first video in which gap strategy is been taught?
@Pepcoding
@Pepcoding 2 жыл бұрын
For better experience, precised content you should visit - nados.pepcoding.com ✅ Signup to NADOS ✅ And boost your coding career
@amanshrivansh2847
@amanshrivansh2847 2 жыл бұрын
Diagonal traversal of an array
@mdnazirhusain1721
@mdnazirhusain1721 2 жыл бұрын
Brust ballon problem solve krne k liye Matrix chain problem dekho ar Matrix chain problem ko solve krne k liya pallendromic cut wali video dekho ye ksa endless loop h😂😂
@umangbehl8152
@umangbehl8152 2 жыл бұрын
as soon as i see your video i ignore others and click on it because you drill the concepts in the head
@hritikanand9734
@hritikanand9734 Жыл бұрын
Osm explanation 😍😍
@mickyman753
@mickyman753 3 жыл бұрын
sir ye questions ko yaad krna pdega kya , kyuki iska method kahi aur nhi lgta hai aur easy to visualise bhi nhi hai
@ArcGaming07YT
@ArcGaming07YT 2 жыл бұрын
is there solution for above with n² complexity
@deeksha6514
@deeksha6514 3 жыл бұрын
Thanks a lot, Sir for this amazing explanation.
@Pepcoding
@Pepcoding 3 жыл бұрын
You are most welcome😊 Keep watching and keep learning🙏
@rohandevaki4349
@rohandevaki4349 2 жыл бұрын
working sir, thanks for the great explaination .
@shivammehta9661
@shivammehta9661 3 жыл бұрын
Very NIce Explanation
@nknidhi321
@nknidhi321 2 жыл бұрын
Maza aa gaya !! ❤️ Thank you 🙏🏼
@kirtimaangogna8468
@kirtimaangogna8468 4 жыл бұрын
Hello sir, Kya aap abi sirf DP k questions complete karoge ya sath me parallel me aur koi topic b karoge ? Agar ap koi aur topic parallel me karoge to uska nam bata dijiye taki wo dusre source se parh k time waste na karen ham, Thank you so much for this awesome content.
@Pepcoding
@Pepcoding 4 жыл бұрын
Hashmap-Heaps parallel mei kar rha hun. Thank you for the kind words.
@HappyHappy-ih5zp
@HappyHappy-ih5zp 3 жыл бұрын
subscribe bhi kr dia and bell notification bhi dba di. Great Content Sir Thank You very Much.
@Pepcoding
@Pepcoding 3 жыл бұрын
Thank you so much keep motivating, keep learning and keep loving Pepcoding😊
@schwarzenneger9240
@schwarzenneger9240 4 жыл бұрын
Sir aap live kyu nhi aate ajkal ? (9pm wala)
@Pepcoding
@Pepcoding 4 жыл бұрын
10 video bnae bina sharam aati hai live ane mei
@sauravsharma4615
@sauravsharma4615 4 жыл бұрын
@@Pepcoding sir is there any way to be teaching assistant in pepcoding ,i have experience
@sauravsharma4615
@sauravsharma4615 4 жыл бұрын
Of 4 months at CN in C++ Data Strt.
@ZentrexGaming
@ZentrexGaming 3 жыл бұрын
Sir, Maza aa gaya. Kya mast samjhate ho aap yaar. LITERAL GOD. I hope god bless you and your family. MAST VIDEO
@nehasht2
@nehasht2 2 жыл бұрын
Love ur explanations ...
@Pepcoding
@Pepcoding 2 жыл бұрын
Thanks a ton. For better experience and well organised content sign up on nados.io And for being updated follow us on Instagram instagram.com/pepcoding/
@nehasht2
@nehasht2 2 жыл бұрын
@@Pepcoding sure
@optimizer_____2420
@optimizer_____2420 3 жыл бұрын
Can it be solved in n2 time complexity as min cut palindrome question?
@Pepcoding
@Pepcoding 3 жыл бұрын
Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.
@priyanshukhullar5836
@priyanshukhullar5836 4 жыл бұрын
Great sir burst balloon bhi post kijiye sir jldi . Aapse sikhna hai
@Pepcoding
@Pepcoding 4 жыл бұрын
hanji. ajkal mei dalega.
@nehaagrawal177
@nehaagrawal177 2 жыл бұрын
sir, gap strategy ka video kaunsa hai
@Pepcoding
@Pepcoding 2 жыл бұрын
visit nados.pepcoding.com, post your doubts; there our community will help you out.
@manishkumarsingh4631
@manishkumarsingh4631 2 жыл бұрын
22/79 Done
@Pepcoding
@Pepcoding 2 жыл бұрын
Keep it up!
@factswithai2
@factswithai2 3 жыл бұрын
as usual "east or west sumeet sir is the best"
@Pepcoding
@Pepcoding 3 жыл бұрын
Keep learning, Keep growing and keep loving Pepcoding!😊
@anurag4316
@anurag4316 3 жыл бұрын
hello sir aap at 19:20 par jo loop lagake bol rahe ho mai umeed karta hu aapko ata hoga uska explanation kaha mil sakta hai apne kisi previous video mae keya hai explain please it will be very helpfull and sir love your videos
@Pepcoding
@Pepcoding 3 жыл бұрын
Here you'll find the gap strategy - www.pepcoding.com/resources/data-structures-and-algorithms-in-java-levelup/dynamic-programming/lps-official/ojquestion. Keep learning and keep growing😊
@devanshubilthare5277
@devanshubilthare5277 3 жыл бұрын
Sir, dp ma confidence nhi aa rha, abhi bhi koi naye question ko soch nhi pata dp ma. Foundation ke saare questions kre ha aur levelup ke bhi 30 questions kr chuka hu dp ke. Koi tip dijiye Sumit sir
@anjneysingh2090
@anjneysingh2090 3 жыл бұрын
Maths and memization
@mickyman753
@mickyman753 3 жыл бұрын
bhai common questions ko group krke revise krte rho ,agr ye 70-80 questions kaise bhi krke aate hia toh aage probability jyada hogi ki question ban jaega
@princypareek2992
@princypareek2992 3 жыл бұрын
Sir pls ek baar iss ka recursive code bhi bata dijiye na..
@Pepcoding
@Pepcoding 3 жыл бұрын
Hanji beta, ek bari jo agenda main questions h vo complete kr le, then ye sb cheeze bhi cover kr lenge
@kushagrashekhawat8227
@kushagrashekhawat8227 4 жыл бұрын
Sir, DP kb tk complete ho jayegi??
@Pepcoding
@Pepcoding 4 жыл бұрын
25 din aur
@NeerajSharma-mz4es
@NeerajSharma-mz4es 3 жыл бұрын
After rod cutting one can easily solve this thanks sir
@Pepcoding
@Pepcoding 3 жыл бұрын
Yes 👍
@mukeshojha9318
@mukeshojha9318 4 жыл бұрын
Sir i am facing problems that i can not convert my logics into code , so i can not solve any of your question without watching your videos but i understand logic quickly. help me sir.
@anjneykumarsingh4461
@anjneykumarsingh4461 4 жыл бұрын
Bhai ap glt jgh agya ye level up h, ap 4-5 baari foundation cover kijiye phir hojayega
@mukeshojha9318
@mukeshojha9318 4 жыл бұрын
@@anjneykumarsingh4461 mai foundation course hi kar rha hu ye letest video tha isliye ispr comment kiya
@Pepcoding
@Pepcoding 4 жыл бұрын
beta, thoda karte karte aaega. 200-300 question jis din kar doge firr nahi aaegi ye problem
@mukeshojha9318
@mukeshojha9318 4 жыл бұрын
@@Pepcoding thanks sir I will not losing hope. You hard work inspired me a lot.
@kunjpatel1703
@kunjpatel1703 3 жыл бұрын
Great Video. Just one thing, this solution is giving TLE in python on pepcoding.
@twicein14days
@twicein14days 2 жыл бұрын
18:45
@rahulbhatia3075
@rahulbhatia3075 4 жыл бұрын
Nice video
@Pepcoding
@Pepcoding 4 жыл бұрын
Thanks
@payalsagar1808
@payalsagar1808 3 жыл бұрын
Epic ❤️
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc
@ashirwadshukla8221
@ashirwadshukla8221 3 жыл бұрын
Million likes video this is
@Pepcoding
@Pepcoding 3 жыл бұрын
Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
@dipuprasad9196
@dipuprasad9196 3 жыл бұрын
Sir apjo samjha dete hai wo kathin bilkul bhi nhi lagta
@b.sainathreddy4567
@b.sainathreddy4567 4 жыл бұрын
nice
@Pepcoding
@Pepcoding 4 жыл бұрын
Thanks
@karanveersingh5535
@karanveersingh5535 2 жыл бұрын
❤️🔥💯
@cyberpolice3183
@cyberpolice3183 3 жыл бұрын
maja aya
@viditvaish7317
@viditvaish7317 3 ай бұрын
i swere no one cam ever match you in terms of explanation
@ayushmansharma5321
@ayushmansharma5321 2 жыл бұрын
//MATRIX CHAIN MULTIPLICATION(Strategy according to recursion example) + Memoization import java.util.*; public class Main{ //Size of the Array is upto 1000.... static int dp[][] = new int [1001][1001]; public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int [n]; for(int i=0;i=j){ dp[i][j] = 0; return 0; } else if (dp[i][j]!=-1) return dp[i][j]; else{ int minimum = Integer.MAX_VALUE; for(int k=i;k
@technicalrobot9685
@technicalrobot9685 Жыл бұрын
// Recursion + DP (Java) import java.io.*; import java.util.*; public class Main { static int dp[][]=new int[1002][1002]; public static int mcm(int[] arr){ return solve(arr, 1, arr.length-1); } public static int solve(int arr[], int i, int j) { if(i>=j){ return 0; } if(dp[i][j] != 0) { return dp[i][j]; } int min = Integer.MAX_VALUE; for(int k=i; k
@manishkumarsingh4631
@manishkumarsingh4631 2 жыл бұрын
22/79 Done
@Pepcoding
@Pepcoding 2 жыл бұрын
Well done
Longest Common Substring Dynamic Programming
27:22
Pepcoding
Рет қаралды 27 М.
Mom had to stand up for the whole family!❤️😍😁
00:39
DaMus
Рет қаралды 1,7 МЛН
didn't manage to catch the ball #tiktok
00:19
Анастасия Тарасова
Рет қаралды 16 МЛН
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 10 МЛН
How To Create A News Channel with AI | 2024
9:40
Website Learners
Рет қаралды 14 М.
Burst Balloon Dynamic Programming | Leetcode Hard Solutions
50:04
some very nice values of cosine
16:11
Michael Penn
Рет қаралды 1,5 М.
Mom had to stand up for the whole family!❤️😍😁
00:39
DaMus
Рет қаралды 1,7 МЛН