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

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024

ความคิดเห็น • 8

  • @adi4178
    @adi4178 2 หลายเดือนก่อน +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];
    }

  • @vira5995
    @vira5995 8 หลายเดือนก่อน +4

    first like

    • @ARYANMITTAL
      @ARYANMITTAL  8 หลายเดือนก่อน

      Yeahhh 🗿❤️❤️, thank youuu !!

  • @ashish3487
    @ashish3487 8 หลายเดือนก่อน +3

    Weekly contest 381 ka 4th ques please bhaiya

    • @ARYANMITTAL
      @ARYANMITTAL  8 หลายเดือนก่อน +2

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

  • @shivamgarg269
    @shivamgarg269 8 หลายเดือนก่อน +1

    Thank you bhai

  • @Panichusko
    @Panichusko 8 หลายเดือนก่อน

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