No doubts for this video but Just letting you know ki you already know what's the probability of doubts of a beginner level coder. Like when you were explaining Form 3 at 10:44 even I was wondering what if there are more than two strings and its starts with the same element as of string A but you explained that too by the end of the video. Tysm😻
We can further optimize it like if (a[i]==b[j]) is true then there is no need to check for rec(a, b, i + 1, j) and rec(a, b, i, j + 1) as making unnecessary recursive calls increases computation. if(a[i]==b[j]) { ans=max(ans,1+rec(a,b,i+1,j+1)); } else{ ans=max(ans,rec(a,b,i+1,j)); ans=max(ans,rec(a,b,i,j+1)); }
I'm kind of finding it difficult to exactly think how this structure of code can exactly be applied to solve longest common substring instead of subsequence. As in that case, we still have the same choices to either take both , or discard any one of the two strings. But the only difference over there is that the indexes chosen have to be consecutive. So do we need to take prev_i and prev_j as two another states or how exactly do we have to proceed in that case ?
Self note: if we are given multiple sequence nd we have to match them somehow or get ans from a(0.....n) and b(4.....m) and c(2.....q) we will use form 3 - multi sequence dp
@@vivekgupta3484 17:37 wale m .....agar wo check nahi karega to rec(i+1 ,j) x string me end tak jaega nd phir rec(i,j+1) y string m end tak ......and after check karega ....this is the confusing.please help sir
Can prefix sum Dp be implemented in recursive solution? Like I just know how to do it with iterative approach but I am not too comfortable with iterative dp.
Tried to solve the longest common substring question using this form and the previous form(2 and 3).The meaning for dp[I][j] -> what is the longest common substring between string a[0....i] and string b[0....j]. The transitions include if the character matches at a[i] and b[j] then we search for the same in string a[0....i-1] and string b[0....j-1] else the return value of the current state is 0.Further on we call the recursive function upon rec(i-1,j) and rec(i,j-1)....Could you please help in coding up this solution since I tried but could not succeed....None the less amazing content once again!
loved this workshop
Another amazing day of dp
Thank you for the video👍
Excellent
No doubts for this video but Just letting you know ki you already know what's the probability of doubts of a beginner level coder. Like when you were explaining Form 3 at 10:44 even I was wondering what if there are more than two strings and its starts with the same element as of string A but you explained that too by the end of the video. Tysm😻
Enjoyed a lot ♥
We can further optimize it like if (a[i]==b[j]) is true then there is no need to check for rec(a, b, i + 1, j) and rec(a, b, i, j + 1) as making unnecessary recursive calls increases computation.
if(a[i]==b[j])
{
ans=max(ans,1+rec(a,b,i+1,j+1));
}
else{
ans=max(ans,rec(a,b,i+1,j));
ans=max(ans,rec(a,b,i,j+1));
}
I'm kind of finding it difficult to exactly think how this structure of code can exactly be applied to solve longest common substring instead of subsequence. As in that case, we still have the same choices to either take both , or discard any one of the two strings. But the only difference over there is that the indexes chosen have to be consecutive. So do we need to take prev_i and prev_j as two another states or how exactly do we have to proceed in that case ?
whenevr s[i]!=SS[j] , make curr_max_length=0;
Nice Video Vivek
Self note: if we are given multiple sequence nd we have to match them somehow or get ans from a(0.....n) and b(4.....m) and c(2.....q) we will use form 3 - multi sequence dp
Understood 😃
Thank you sir
great class.
understood.
🔥 thanks ☕☕
Yup present
please do a session on common leetcode problem using these forms
discuss more patterns that we can solve using only these forms.
🔥🔥🔥
in which lecture you have explained calculation of Time Complexity??
He explained it in Day 2 part 2.
@@SatyamKumar-yz5gk ok will watch it,Thenks :D..
Line 21 wale code m ....jo if() statement hai usko line 19 se upar hona chahiye n????
Not necessary.. which timestamp?
@@vivekgupta3484 17:37 wale m .....agar wo check nahi karega to rec(i+1 ,j) x string me end tak jaega nd phir rec(i,j+1) y string m end tak ......and after check karega ....this is the confusing.please help sir
The following code exceeds time limit on leetcode. What to do?
Will there be any more videos today??
Can prefix sum Dp be implemented in recursive solution? Like I just know how to do it with iterative approach but I am not too comfortable with iterative dp.
Can we do interleaving string in live using form 3.
what if there are more than 3 strings, do we need to write cases for each like if 4 strings then will take 4 index and do the same stuff?
Yes. If here are N, then maybe you can keep a vector and that would be much more efficient.
🛐
👍
In case of n strings how we will do it as it won’t be wise to have n states 🤔
Will take in separate video.
bhaiya what about the iterative form? how to write that?
we learn that in next days
@@vivekgupta3484 bhaiya you mean in lecture 24?
i meant from day 5 onwards we see how to code in iterative way
@@vivekgupta3484 thanks bhaiya
when i submit the code on gfg it is giving tle
Which problem?
@@vivekgupta3484 longest common subsequence for two string s
Tried to solve the longest common substring question using this form and the previous form(2 and 3).The meaning for dp[I][j] -> what is the longest common substring between string a[0....i] and string b[0....j]. The transitions include if the character matches at a[i] and b[j] then we search for the same in string a[0....i-1] and string b[0....j-1] else the return value of the current state is 0.Further on we call the recursive function upon rec(i-1,j) and rec(i,j-1)....Could you please help in coding up this solution since I tried but could not succeed....None the less amazing content once again!
attendance +1
👍