139. Word Break | Day 018 | Recursion | Top Down DP | Bottom Up DP | Trie

Поделиться
HTML-код
  • Опубликовано: 5 ноя 2024

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

  • @adi4178
    @adi4178 3 месяца назад +3

    You explain well all concept. Please don't mind my comment just i want to get clearified.
    In top down we went from 0 to n-1 index but in Bottom Up here shouldn't we go from n-1 to 0 ?
    bool wordBreak(string s, vector& wordDict) {
    int n=s.length();
    vectordp(n+1,false);
    dp[n]=true;
    for(int ind = n-1;ind>=0 ;ind--)
    {
    for(string currentWord : wordDict)
    {
    int len = currentWord.length();
    if(ind + len - 1 >= s.length())
    continue;

    if((s.substr(ind,len)==currentWord) && dp[ind+len])
    {
    dp[ind]=true;
    }
    }
    }
    return dp[0];
    }

  • @shivamgarg269
    @shivamgarg269 9 месяцев назад +1

    Thank you bhai

  • @ashish3487
    @ashish3487 9 месяцев назад +3

    Weekly contest 381 ka 4th ques please bhaiya

    • @ARYANMITTAL
      @ARYANMITTAL  9 месяцев назад +2

      Yes sir, time nhi mil paa raha 😭, but jaldi aaega 🤌🏻

  • @vira5995
    @vira5995 9 месяцев назад +4

    first like

    • @ARYANMITTAL
      @ARYANMITTAL  9 месяцев назад

      Yeahhh 🗿❤️❤️, thank youuu !!

  • @abudanish196
    @abudanish196 Месяц назад

    Your explanations are very complicated and long. Make short and crisp videos like striver.

  • @Panichusko
    @Panichusko 9 месяцев назад

    bhai please explain 3017. Count the Number of Houses at a Certain Distance II this question it's very hard to understand the question