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;
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];
}
We can go
Thank you bhai
Weekly contest 381 ka 4th ques please bhaiya
Yes sir, time nhi mil paa raha 😭, but jaldi aaega 🤌🏻
first like
Yeahhh 🗿❤️❤️, thank youuu !!
Your explanations are very complicated and long. Make short and crisp videos like striver.
bhai please explain 3017. Count the Number of Houses at a Certain Distance II this question it's very hard to understand the question