Count Ways To Build Good Strings | Bottom Up | Leetcode 2466 | codestorywithMIK

Поділитися
Вставка
  • Опубліковано 6 січ 2025

КОМЕНТАРІ • 32

  • @JJ-tp2dd
    @JJ-tp2dd Рік тому +8

    Just unbelievable bhai..magical ♥💙 . Java implementation:
    class Solution {
    public int countGoodStrings(int low, int high, int zero, int one) {

    int mod = 1000000007;

    //t[i] == number of good strings of length i
    int [] t = new int[high+1];
    t[0] = 1; // ""

    for(int i=1; i= 0)
    t[i] = (t[i]%mod + t[i-zero]%mod)%mod;

    if(i-one >=0)
    t[i] = (t[i]%mod + t[i-one]%mod)%mod;
    }

    int ans = 0;

    for(int l=low; l

  • @HeetVichhivora
    @HeetVichhivora 7 днів тому +1

    Mik bhai aap bohot sahi ho sachi me matlb kya bolne ka itna mast samjate ho

  • @Your_Boy_Suraj
    @Your_Boy_Suraj Рік тому +3

    Bhai Jaisa Graph Series ko Scratch se padhaya waise hi please ek Tree series bhi bana do na and Ryan ki baate include karna bilkul mat bhulna, usse energy level maintain rehta hai!!
    Thank you for the Graph series... Kaafi underrated content hai and ye channel bhi❤

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +1

      Sure Suraj
      Thank you so much for watching ❤️❤️❤️

  • @sanjaykatta6499
    @sanjaykatta6499 Рік тому +3

    For Viewers - switch to 1.5x for better experience!

  • @abhisheksingh-rz8nj
    @abhisheksingh-rz8nj 8 днів тому +2

    class Solution {
    public:
    int loww, highh, zeroo, onee;
    int dp[100005];
    int mod = 1e9+7;
    int rec(int len){
    //base case
    if(len>highh)return 0;
    int count = 0;
    if(len>=loww && len

  • @India_mera_sabkuch
    @India_mera_sabkuch 7 днів тому +1

    sir you are not a teacher you are absolute magician!! .....sir aap kha rahte ho ye bataoge kabhi aan hua to milne jarur aaunga, please sir!!

  • @JJ-tp2dd
    @JJ-tp2dd Рік тому +5

    really looking forward to your dp concepts series. Ek suggestion/request h.. Jb ap concepts smjhaoge dp series me and then us concept pe question karaoge toh please 9-10 similar pattern k question link kr dena ya question no comment me dena so that practice ho paye..🥺🥺

  • @sanjaykatta6499
    @sanjaykatta6499 Рік тому +2

    Bro, will there be a situation where the interviewer specifically asks for bottom up approach?
    Is this just to know another approach apart from top down and or does this have any added advantage?
    Because somehow I feel top down approach is more intuitive than the bottom up.

  • @YashMalav-kh1ov
    @YashMalav-kh1ov 7 місяців тому

    Bhaiya jbb ham t[0] = 1 le rhe hai means zero length kitni good strings to it show have followed naa ki uski len mtlb zero low aur high ke bich ho tbb hi apn t[0] kr skte hai??

  • @cabbi9
    @cabbi9 7 днів тому

    Sir waise toh mai samajh gaya aap ka bottom-up karne ka method.
    But maine ye code likha tha khud se when i saw this question, kya hum isko kuch karke convert kar sakte hai iterative dp mein?
    class Solution {
    public:
    const int mod = 1e9 + 7;
    int low, high, zero, one;
    int dp[100010];
    int solve(int sz) {
    if (sz > high)
    return 0;
    if (dp[sz] != -1)
    return dp[sz];
    int cnt = 0;
    if (low high = high;
    this->zero = zero;
    this->one = one;
    memset(dp, -1, sizeof(dp));
    return solve(0);
    }
    };

  • @sunnyvlogs__
    @sunnyvlogs__ Рік тому +4

    Bhaiya In interviews Top-down (recur+memo) is sufficient or we need to practice Bottom up as well?

    • @codestorywithMIK
      @codestorywithMIK  Рік тому

      Bottom up has been increasingly become important for interviews of Top tech companies.

  • @souravjoshi2293
    @souravjoshi2293 Рік тому +3

    L.E.G.E.N.D

  • @ManojKrVerma-vw4dx
    @ManojKrVerma-vw4dx Рік тому +1

    First if case mei rvalue mei t[i] ki need kya hain?

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +1

      you can skip it since it’s the first if condition.

  • @venkatarohitpotnuru38
    @venkatarohitpotnuru38 6 місяців тому

    Supper

  • @codeandtalk6
    @codeandtalk6 Рік тому +1

  • @satyamkumaryadav1560
    @satyamkumaryadav1560 Рік тому +1

    sir i have one simple doubt aap empty string ko as a good string count kr rahe jaise t[0]=1 toh t[1]=2 hona chaiye us logic se please clear this doubt

    • @codestorywithMIK
      @codestorywithMIK  Рік тому

      Actually if you remember I told that if we set t[0] = 1
      Then whole array will be 0 till the end.
      Sometimes there are questions where we do something like this.
      One similar Qn is Minumum Subset Sum in DP bottom up.
      I will be starting DP concepts playlist where I will be teaching all these things too

    • @satyamkumaryadav1560
      @satyamkumaryadav1560 Рік тому +1

      @@codestorywithMIK sir please start asap in 2-3 months we will be having our placement month so it will be very kind of you if you start soon , because there are small concepts like this which we lack and are unable to solve problems

    • @codestorywithMIK
      @codestorywithMIK  Рік тому

      Sure thing ❤️❤️

  • @wearevacationuncoverers
    @wearevacationuncoverers Рік тому +2

    Dude, when do you rest ? Weekends (I don't think so)

  • @yashgarg3027
    @yashgarg3027 Рік тому

    Bhaiya plz 1 request next aaj 1 video upload kr do on today biweekly leetcode contest 3 question maximum xor

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +1

      Hi Yash,
      Actually i am spending most of my time today with my mom celebrating Mother’s.
      I will definitely come up with the video soon for that. Thank you for trusting my channel and the patience ❤️❤️

  • @Brute_Coder
    @Brute_Coder Рік тому

    can anyone help me to debug this code ??
    class Solution {
    int mod = 1000000007;
    public int countGoodStrings(int low, int high, int zero, int one) {
    int[] dp = new int[high+1];
    Arrays.fill(dp,0);
    dp[0] = 1;

    for(int i = 1;i= 0) ? dp[i-zero] : 0;
    int foro = ((i-one) >= 0) ? dp[i-one] : 0;
    dp[i] = forz%mod + foro%mod;
    }
    int ans = 0 ;
    for(int i = low ;i