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

Комментарии • 43

  • @ManojKrVerma-vw4dx
    @ManojKrVerma-vw4dx Год назад +6

    Your way of teaching is simply awesome. Why it looks so easy after watching your solution.. Thank You.

  • @amarjeet_kumar0987
    @amarjeet_kumar0987 Год назад +2

    bhai your teaching and explaination dil ko chhoo jata h . really nice❤❤

  • @DhruvSharma-mh5vf
    @DhruvSharma-mh5vf Год назад +2

    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 🎉

  • @ankitrajsahay
    @ankitrajsahay Год назад +4

    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.

    • @codestorywithMIK
      @codestorywithMIK  Год назад +2

      You made my day. Thank you so much.
      Bottom up loaded now ❤️❤️

  • @vishalplayzz2580
    @vishalplayzz2580 Год назад +1

    to avoid confusion of boolean variable (remove bool variable )
    u can write that as
    if(i>=l && i

  • @AlishaKhan-ww3io
    @AlishaKhan-ww3io Год назад +2

    Done because of you ,. Thanks

  • @user-mt2vj1hi8z
    @user-mt2vj1hi8z Год назад +3

    This was actually a very good explanation. Thanks!

  • @oqant0424
    @oqant0424 Год назад +2

    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

    • @codestorywithMIK
      @codestorywithMIK  Год назад +1

      Thank you so much.❤️❤️
      Sure, i will definitely do that.

  • @mohithadiyal6083
    @mohithadiyal6083 Год назад +2

    Best explanation 👍

  • @anuppatankar4294
    @anuppatankar4294 Год назад +2

    As always great video👌🏻

  • @doomhead9109
    @doomhead9109 Год назад +1

    17:00 i used the same string manipulation but got tle

  • @UmeshBisht-ik4li
    @UmeshBisht-ik4li Год назад +1

    Thanku bhaiya ❤

  • @rohitmarthak7747
    @rohitmarthak7747 Год назад +1

    Great one

  • @tutuimam3381
    @tutuimam3381 Год назад +1

    Best suletion

  • @thekindspill
    @thekindspill Год назад +1

    New subscriber

  • @PramodKumar-bu2uf
    @PramodKumar-bu2uf Год назад +2

    apne tree digram mae 0 ki jagah 1 le liya hai first dry run right hand side

    • @codestorywithMIK
      @codestorywithMIK  Год назад +2

      Ah silly mistake. Thanks for pointing out ❤️

    • @vedbhanushali608
      @vedbhanushali608 Год назад +1

      @@codestorywithMIK I was also confused but after seeing this comment I got it. please pin this comment at top

    • @codestorywithMIK
      @codestorywithMIK  Год назад

      Thanks @Only Code for pointing this out and helping others.
      Let me add a caption in the video itself to correct it

  • @harshaggarwal1967
    @harshaggarwal1967 Год назад

    what is the tc and sc for this solution?

  • @dhairyachauhan6622
    @dhairyachauhan6622 Год назад +1

    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

  • @rahulmaurya6451
    @rahulmaurya6451 Год назад +1

    Bhaiya hm log boolean variable kyu le rhe hai,, sidhe 1 return kyu nhi kr rhe ?

    • @sunnyvlogs__
      @sunnyvlogs__ Год назад +4

      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

    • @codestorywithMIK
      @codestorywithMIK  Год назад +1

      I got your qn now after seeing @sunny’s answer.
      Thanks for clarification

    • @rahulmaurya6451
      @rahulmaurya6451 Год назад +2

      ​@@sunnyvlogs__ yaa ,, you're right bro

  • @codeandtalk6
    @codeandtalk6 Год назад +1

  • @ManojKrVerma-vw4dx
    @ManojKrVerma-vw4dx Год назад +2

    I couldn't solve this question by my own. So disappointing..

    • @codestorywithMIK
      @codestorywithMIK  Год назад +1

      Don’t worry. We all will grow together ❤️❤️

  • @souravjoshi2293
    @souravjoshi2293 Год назад

    Yeah I am growing with this channel

  • @satyamshukla2389
    @satyamshukla2389 Год назад +1

    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

  • @JJ-tp2dd
    @JJ-tp2dd Год назад +2

    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

  • @yatri6329
    @yatri6329 Год назад

    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

  • @yatri6329
    @yatri6329 Год назад

    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