Longest Common Substring Dynamic Programming

  Рет қаралды 27,660

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. Here you will learn about the Longest Common Substring . In this question :
1. You are given two strings S1 and S2.
2. You are required to print the length of the longest common substring of two strings.
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

Пікірлер
@VKBMath
@VKBMath 3 жыл бұрын
This type of content is free unbelievable Love you Sumeet sir what a teacher ❤️❤️❤️❤️❤️❤️
@Pepcoding
@Pepcoding 3 жыл бұрын
wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
@prateeksharma3698
@prateeksharma3698 3 жыл бұрын
No one gave this kind of insight of the problem , the WHY portion explained is excellent. Thanks Sir for such a great content.
@simakeshri5890
@simakeshri5890 2 жыл бұрын
Aaj real meaning smj m aaya,baki log to bus dp bharna batate h. 👍👍. Thank you sir for these free content
@sadmanabedin1203
@sadmanabedin1203 3 жыл бұрын
I solved this problem without even watching this video, using the techniques brother Sumeet taught in earlier problems like Longest palindroming substring, longest common subsequence etc. That proves how extremely good he is at teaching these staffs. Keep it up bro.
@kartikshrivastava1500
@kartikshrivastava1500 Жыл бұрын
When asked how some tabulation solution works very few people know what's happening inside it, you are the one who knows inside-out of it, thanks a lot for sharing!
@samarthjain5295
@samarthjain5295 3 жыл бұрын
This video deserves a like tbh, I have seen so many videos on this question but this is the only video saying that why it is happening .Thank you
@shashwatagarwal867
@shashwatagarwal867 Жыл бұрын
This is by far the most amazing explanation to this problem. Hats off!
@Ali-ok8yn
@Ali-ok8yn 3 жыл бұрын
Best explanation for this question on the internet. DP solutions are always easy but the important part is how you reached that solution and you have explained that really well.
@abhinavagrawal6148
@abhinavagrawal6148 3 жыл бұрын
The way he explains agar koi interview me explain kre to interviewer wahi fan ho jaye.
@sameersondur9030
@sameersondur9030 Жыл бұрын
There are only 2 words that come to my mind!! ekdum jhakaas!!!! I had seen 3 videos till now for this problem and this is the first video I understood.
@a026devpatelsvnit7
@a026devpatelsvnit7 3 жыл бұрын
This is the most underrated channel for programming on youtube
@basudebshyam7840
@basudebshyam7840 3 жыл бұрын
Why u did? J
@sahilanower9189
@sahilanower9189 2 жыл бұрын
This channel is a life saver
@rishabhkumar8115
@rishabhkumar8115 3 жыл бұрын
i really impressed by your explanation. thanks man for this.
@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 write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
@helloword3544
@helloword3544 3 жыл бұрын
This question can be done in other way also , i.e, we can also evaluate longest common substring by comparing all suffixes of s1 with all suffixes of s2 and find the longest common prefix .
@Pepcoding
@Pepcoding 3 жыл бұрын
yes, true.
@mickyman753
@mickyman753 3 жыл бұрын
can you share your code
@abhisheksamari4591
@abhisheksamari4591 2 жыл бұрын
Excellent explaination
@imajt5
@imajt5 3 жыл бұрын
Dil se thank you bhai for providing the best content and giving so much time and effort to help us.
@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 write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
@TheDev05
@TheDev05 Жыл бұрын
All time GOAT, Summet Sir! 🙏
@shivammehta9661
@shivammehta9661 3 жыл бұрын
Awesome Explanation......Keep making videos
@democrats9579
@democrats9579 3 жыл бұрын
Woah❤ isse kehte h explaination🙌, this was amazing!
@shivcharansinghrawat4224
@shivcharansinghrawat4224 2 жыл бұрын
THE BEST EXPLANATION !!!!!!
@Pepcoding
@Pepcoding 2 жыл бұрын
Thank you! Cheers! For better experience and precisely arranged content visit on nados.pepcoding.com Don't forget to follow us on Instagram instagram.com/pepcoding/
@rakshaverma3673
@rakshaverma3673 3 жыл бұрын
you are really too good sir.......
@vivekgupta_3085
@vivekgupta_3085 2 жыл бұрын
Good Content as usual .
@gaunikasrivastava7851
@gaunikasrivastava7851 2 жыл бұрын
This explanation really gave a feel of the solution. Even better than AV's video
@Pepcoding
@Pepcoding 2 жыл бұрын
Glad, it was helpful For better experience and well organised content sign up on nados.io
@AnandKumar-kz3ls
@AnandKumar-kz3ls 2 жыл бұрын
we can use unordered_set and time complexity can reduced to n^3
@akshayjadhav4199
@akshayjadhav4199 2 жыл бұрын
super explained 💥💥💥💥💥💥💥💥
@akshatgupta2607
@akshatgupta2607 2 жыл бұрын
One of the best explanation ❤️
@varsha4260
@varsha4260 4 жыл бұрын
Sir,Please make a video on a backtracking solution of longest comon substring.
@stutij7922
@stutij7922 3 жыл бұрын
Extremely well explanation sir
@yashgoyal6079
@yashgoyal6079 3 жыл бұрын
Wonderful explanation sir🙏🙏🙏🙏
@aemenlodhi
@aemenlodhi 3 жыл бұрын
Great explanation. Thank you!
@indranilchakraborty5949
@indranilchakraborty5949 3 жыл бұрын
nice explanation sir...... akdm clear ho gya.😊😊😊😊
@Pepcoding
@Pepcoding 3 жыл бұрын
Bhot he bdiya, aise he lge rho aur bdte rho😊🙏
@aman6561
@aman6561 4 жыл бұрын
Sr bina trick jaane ke sbhi prefix ka common suffix ans hai to kaafi mushkil hai complexity km krna. agr trick pta ho tbhi hoga km complexity me
@cplearners9244
@cplearners9244 3 жыл бұрын
Sir, please make a video on finding common substring of n strings.
@pranjalsharma499
@pranjalsharma499 4 жыл бұрын
Sir you are doing a very good job, keep going
@Pepcoding
@Pepcoding 4 жыл бұрын
Thank you, I will
@simrankak7045
@simrankak7045 3 жыл бұрын
sir your explaination is so very good thankyou :)
@sarveshmishra8416
@sarveshmishra8416 3 жыл бұрын
Wonderful explanation !!
@RohitKumar-po5qt
@RohitKumar-po5qt 3 жыл бұрын
Brilliant brilliant brilliant !!!!
@lochannatesh6684
@lochannatesh6684 3 жыл бұрын
MInd blowing explanation...super
@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 )
@AnkitSingh-xp7mm
@AnkitSingh-xp7mm 3 жыл бұрын
I was wondering, brute force complexity should be : O(n^2 + m^2 + n.m). O(n^2) for prefix of first string. O(m^2) for prefix of second string. Then Each element of first prefix list gets compared with second prefix list. Hence O(n.m) Total Complexity: O(n^2 + m^2 + n.m). Please correct me if I am wrong.
@mickyman753
@mickyman753 3 жыл бұрын
n^2 susbtring will be made of first list ,m^2 in another , we will compare everyone of them so n^2*m^2 and each string comapision will take k(max len of both) time , so n^2*m^2*k
@cracko3483
@cracko3483 3 жыл бұрын
Great Explanation Sir
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou beta 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 )
@cracko3483
@cracko3483 3 жыл бұрын
@@Pepcoding Done Sir
@harshvardhansingh780
@harshvardhansingh780 2 жыл бұрын
Great explanation sir
@Pepcoding
@Pepcoding 2 жыл бұрын
Glad you liked it! Keep learning And for better experience, visit nados.io, where you will get well curated content and career opportunities.
@parthmadan671
@parthmadan671 2 жыл бұрын
Awesome
@MGtvMusic
@MGtvMusic 2 жыл бұрын
Some space optimisation : class Solution{ int longestCommonSubstr(String S1, String S2, int n, int m){ // code here int[] prev = new int[S2.length()+1]; int max = 0; for(int i=1;i
@vaibhavjha5938
@vaibhavjha5938 4 жыл бұрын
👍. Sir can you plzz guide me regarding scope of placement after doing MTECH from IITB.I mean to say if I do good there will I get good tech companies.
@amandixit3555
@amandixit3555 3 жыл бұрын
ok , whosoever understood this question try thinking out can we do like we are going to store in each cell i , j the LCS between s1(0,i) and s2(0,j). If you figured out the way doing so ,good and if not , why not . comment down below. This will make the understanding of this question crystal clear in your mind. #HAPPYCODING.
@stevejob677
@stevejob677 3 жыл бұрын
thank you so much sir
@ashwinnema06
@ashwinnema06 2 жыл бұрын
This is the first question of tabular dp I solved without watching the solution
@sarveshchavan4391
@sarveshchavan4391 3 жыл бұрын
Nice explain ❤️❤️
@aman6561
@aman6561 3 жыл бұрын
sir leetcode pr problem krra tha hashmap tag ki to usme ye question bhi tha bs array die the string ki jgh mne to dp lgaa kr submit krdia lekin solution me hashmap se bhi solution tha kch ROLLING HASH krke kya hota hai sr ye?.
@tanishkumar6682
@tanishkumar6682 Жыл бұрын
understood
@manishkumarsingh4631
@manishkumarsingh4631 2 жыл бұрын
38/79 done
@MGtvMusic
@MGtvMusic 2 жыл бұрын
Love you
@madhavchaturvedi4654
@madhavchaturvedi4654 3 жыл бұрын
sir ji ye vala question memoization se kardo plz.Iska recursive formula banana bohot mushkil pad raha hai
@RitikKumar-bk6pj
@RitikKumar-bk6pj 2 жыл бұрын
Sir please tell how we will get the longest common string not their length?
@RitikKumar-bk6pj
@RitikKumar-bk6pj Жыл бұрын
@@Kashish_Batra thank u so much
@SudhanshuKumar-jl8iw
@SudhanshuKumar-jl8iw 3 жыл бұрын
I like your explaination ways what?how ?why?it make me think a problem of dp easy ???
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou beta, I am glad you liked it. I also hope that you are watching till end. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
@priyanshugupta8299
@priyanshugupta8299 2 жыл бұрын
Can't we just solve it like longest common subsequence and simply store 0 whenever characters are unequal
@Pepcoding
@Pepcoding 2 жыл бұрын
For better insight, visit nados.pepcoding.com, post your doubts, community will help you out there.
@rahulborule8619
@rahulborule8619 3 жыл бұрын
Can anyone guide me if I want to print that substring itself as output then how should I proceed
@mickyman753
@mickyman753 3 жыл бұрын
you can take out the length of substring first and store the i and j index of that column , s.susbtring(i-lcs,i) [this is java substring method] will be our answer
@randomname2444
@randomname2444 4 жыл бұрын
Sir, Can you upload egg drop problem tomorrow?
@Pepcoding
@Pepcoding 4 жыл бұрын
aj nahi kal
@schwarzenneger9240
@schwarzenneger9240 4 жыл бұрын
sir 8 easy questions aane the na dp se pehle ?
@subhamthakur565
@subhamthakur565 4 жыл бұрын
bhai aane de jo video daal rhe h saahi h SIR kuch soch ke hi daal rhe honge
@schwarzenneger9240
@schwarzenneger9240 4 жыл бұрын
@@subhamthakur565 yar sir ne khud hi kaha hai ki pehle 8 easy fir 2 dp isliye pucha
@shubhamaggarwal8957
@shubhamaggarwal8957 3 жыл бұрын
brute complexity will be n(n2 +m2) no n. n2 .m2
Longest Repeating Subsequence | Advanced Dynamic Programming
18:51
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 10 МЛН
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 77 МЛН
BIGG BOSS 18 ROAST! FT RAJAT DALAL & POOKIE BABA
16:13
Thugesh
Рет қаралды 1,9 МЛН
Burst Balloon Dynamic Programming | Leetcode Hard Solutions
50:04
LRDI Practice for CAT 2024 | Mean, Median & Mode | Puzzle - 1
22:25
ELITES GRID - CAT PREP
Рет қаралды 6 М.
Matrix Chain Multiplication Dynamic Programming
40:16
Pepcoding
Рет қаралды 46 М.
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 10 МЛН