@mr.encoder can you show dry run how the recursion states works? for this problem?
this is code–> i cannot understand
class Solution {
public:
unordered_map<string,bool> m;
bool ispossible(string s,int start){
if(start==s.length()){
return true;
}
for(int i=start+1;i<=s.length();i++){
string word=s.substr(start,i-start);
if(m.count(word)!=0 and ispossible(s,i)){
return true;
}
}
return false;
}
bool wordBreak(string s, vector<string>& wordDict) {
for(int i=0;i<wordDict.size();i++){
m[wordDict[i]]=true;
}
return ispossible(s,0);
}
};
question–>