DP - 7: Longest common Substring

  Рет қаралды 11,477

Coding Simplified

Coding Simplified

Күн бұрын

Пікірлер: 30
@naamhaii
@naamhaii Жыл бұрын
can be solve it using top down approach
@anirbanchakraborty690
@anirbanchakraborty690 4 жыл бұрын
Your videos are great! very detailed and clear cut! please keep making such videos :)
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Thanks Anirban for your feedback. Keep Watching.
@electronicseverywhere204
@electronicseverywhere204 Жыл бұрын
Send me recursive code of this q , i understood your explanation :)
@surajgrandhi6742
@surajgrandhi6742 4 жыл бұрын
Very good explanation sir, Best DP series , will try to solve remaining
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Thanks Suraj for your nice feedback. Keep Watching.
@pratyushvatsa7490
@pratyushvatsa7490 3 жыл бұрын
3:20 - That is the longest common *subsequence*
@sharuk3545
@sharuk3545 3 жыл бұрын
One of the best solution on youtube
@CodingSimplified
@CodingSimplified 3 жыл бұрын
Thanks for your nice feedback. Keep Watching.
@omprakashsharma9767
@omprakashsharma9767 4 жыл бұрын
This is best solution so far i seen gr8 work bro :)
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Glad to hear that. Thanks.
@raman-jn6yt
@raman-jn6yt 4 жыл бұрын
Hi, I need one help. In the previous problems you explained, our answer is generally stored in the last cell of our solution matrix i.e. sol[m][n]. But in this problem, we have to find maxLCS from our solution 2d-matrix Can you explain that how we decide this?
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Decision is made depending on the requirement & storage we've. In this question, we can't apply the same as sol[m][n], as max LCS can be at any place, so whenever there's change we're updating maxLCS & returning as answer. Thanks.
@coollatchu
@coollatchu 4 жыл бұрын
Can you please elaborate why we need to fill 0's in first row and in first column?
@shankysays
@shankysays 8 ай бұрын
Base condition
@aj9706
@aj9706 3 жыл бұрын
Sir could u explain how to convert recursive dp to bottom up dp iterative version. Recursive solutionz are expensive in hackerearth contests due to stack over flow. Converting to iterative is quite difficult requires lot of practice.
@ram-pc4wk
@ram-pc4wk 2 жыл бұрын
Aditya Verma channel
@ram-pc4wk
@ram-pc4wk 2 жыл бұрын
Here u can find
@ujjwaljain9780
@ujjwaljain9780 4 жыл бұрын
Sir why we are not initialised the first row and column ,u directly started with I=1 and j=1.wht about I=0 and j=0???
@dandesatvikreddy4424
@dandesatvikreddy4424 2 жыл бұрын
that comes in picture ..he just did if(n==0||m==0)just make it as zeros ..... the first row and first column is n=0&m=0..
@vastauine6398
@vastauine6398 3 жыл бұрын
you could have used memoization and changed recursion complexity to O(MN)
@dipteshkumar7247
@dipteshkumar7247 3 жыл бұрын
can you please provide memorization source code?
@himanshubansal6425
@himanshubansal6425 4 жыл бұрын
top to bottom dp solution is missing.
@raman-jn6yt
@raman-jn6yt 4 жыл бұрын
Hi, Would you please highlight purpose of adding 'countOfLCS' in method parameter? I am trying below solution. Would you let me know what is the problem here? private static int lcsRec(String s1, String s2, int m, int n) { /** base condition - if any string is empty, there is no common substring so return 0 */ if (m < 0 || n < 0) return 0; int lcs1, lcs2, lcs3; if (s1.charAt(m) == s2.charAt(n)) lcs1 = 1 + lcsRec(s1, s2, m-1, n-1); else lcs1 = lcsRec(s1, s2, m-1, n-1); lcs2 = lcsRec(s1, s2, m-1, n); lcs3 = lcsRec(s1, s2, m, n-1); return Math.max(Math.max(lcs1, lcs2), lcs3); } Thanks
@CodingSimplified
@CodingSimplified 4 жыл бұрын
'countOfLCS' is representing length of Longest Common Substring. - Try with some example like str1 = "abc" & str2 = "abc" - Another example str1 = "abc" & str2 = "ebc" Try to run pseudo code on these example for better understanding.
@shobhitgarg6897
@shobhitgarg6897 3 жыл бұрын
DO you get the answer for this problem?Please help!
@aj9706
@aj9706 3 жыл бұрын
It's wrong ur doing longest common subsequence
@BlokeBritish
@BlokeBritish 2 жыл бұрын
yeh 'subeestring' kya hai
@ahmedsamir1601
@ahmedsamir1601 4 жыл бұрын
Great Keep going bro
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Thanks. Keep Watching.
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36
Зу-зу Күлпаш 2. Бригадир.
43:03
ASTANATV Movie
Рет қаралды 482 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Proofs in mathematics
46:44
Fondation Hugot du Collège de France
Рет қаралды 10 М.
Leetcode 46. Permutations : Introduction to backtracking
10:06
ComputerBread
Рет қаралды 99 М.
Introduction to Microprocessors | Bharat Acharya Education
1:26:30
Bharat Acharya Education
Рет қаралды 8 МЛН
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36