Count Ways To Build Good Strings | Recur + Memo | META | Leetcode-2466 | Live Code + Explanation
HTML-код
- Опубликовано: 14 окт 2024
- This is the 31st Video on our Dynamic Programming (DP) Playlist.
In this video we will try to solve a very good and another classic DP Problem "Count Ways To Build Good Strings" (Leetcode - 2466)
Trust me, this will no longer be a Medium Problem. I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will solve it using
1. Recursion + Memo - This Video (Video-31)
2. Bottom Up - Upcoming Video (Video-32)
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Count Ways To Build Good Strings
Company Tags : META
My solutions on Github : github.com/MAZ...
Leetcode Link : leetcode.com/p...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZ...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Your way of teaching is simply awesome. Why it looks so easy after watching your solution.. Thank You.
bhai your teaching and explaination dil ko chhoo jata h . really nice❤❤
Means a lot ❤️❤️❤️
Awesome godly explanation, though I had already solved the question even then I came to watch the video to get the clearest of insights❤❤ you are awesome 🎉
Bhaiya i hope aap ye comment dekhe. Dp mein i always get stuck at some point. Confidence nahi aa raha tha. But apki videos dekh ke now i can solve dp recursive way in 2-3 min after making a rough tree structure. Thank you so much bhaiya. Infact, considering today's problem also. The very first observation came into my mind was only length is varying with condition, no there was no need of taking empty string as an argument and passing parameter to it. Thank you. Dp iterative way pe achi se tutorial video bana dijiye. It'll be really helpful. Thank you.
You made my day. Thank you so much.
Bottom up loaded now ❤️❤️
to avoid confusion of boolean variable (remove bool variable )
u can write that as
if(i>=l && i
Done because of you ,. Thanks
This was actually a very good explanation. Thanks!
Thank you so much 👨🏻💻
u made this question so so easy :)
thanks
a small request to u bhaiya:
please discuss time and space complexities at end of every question
Thank you so much.❤️❤️
Sure, i will definitely do that.
Best explanation 👍
Thanks a lot Mohit ❤️❤️
As always great video👌🏻
Thanks a lot ❤️❤️
17:00 i used the same string manipulation but got tle
Thanku bhaiya ❤
Great one
❤️❤️
Best suletion
New subscriber
apne tree digram mae 0 ki jagah 1 le liya hai first dry run right hand side
Ah silly mistake. Thanks for pointing out ❤️
@@codestorywithMIK I was also confused but after seeing this comment I got it. please pin this comment at top
Thanks @Only Code for pointing this out and helping others.
Let me add a caption in the video itself to correct it
what is the tc and sc for this solution?
ALTERNATE ANOTHER INTUITIVE SOLUTION:
class Solution {
public:
int mod = 1e9 + 7;
int solve(int low,int high, int zero, int one,int currlen,vector&dp){
if(currlen>high){
return 0;
}
if(dp[currlen]!= -1){
return dp[currlen];
}
if(currlen=low && currlen
Bhaiya hm log boolean variable kyu le rhe hai,, sidhe 1 return kyu nhi kr rhe ?
Because if you directly return 1 then you can miss those cases which could be counted in our answer that lies in range. Low to high
I got your qn now after seeing @sunny’s answer.
Thanks for clarification
@@sunnyvlogs__ yaa ,, you're right bro
❤
I couldn't solve this question by my own. So disappointing..
Don’t worry. We all will grow together ❤️❤️
Yeah I am growing with this channel
Hey mik please help, my code is failing at testcase 26. I cannot figure out why.
class Solution {
int mod = 1000000009;
int[] dp;
public int countGoodStrings(int low, int high, int zero, int one) {
dp = new int[high + 1];
Arrays.fill(dp, -1);
return solve(low, high, zero, one, 0);
}
int solve(int l, int h, int z, int o, int size) {
if(size > h) {
return 0;
}
if(dp[size] != -1) {
return dp[size];
}
int c = 0;
if(size >= l && size
yar 10^9 + 7 ko 10^9 + 9 leliya tha. Dumb me. Thank You for the video
Glad it’s resolved
Java Implementation :
class Solution {
private int mod;
private int solve(int low, int high, int zero, int one, int[] dp, int l) {
if(l > high) {
return 0;
}
if(dp[l] != -1) {
return dp[l];
}
int addOne = 0;
if(l >= low && l
Thanks man
class Solution {
public int countGoodStrings(int low, int high, int zero, int one) {
String zeroSt=new String();
String oneSt=new String();
for(int i=0;i
class Solution {
int modulo =1000000007;
public int countGoodStrings(int low, int high, int zero, int one) {
String zeroSt=new String();
String oneSt=new String();
int dp[][]=new int[high+1][high+1];
for(int i=0;i