您的位置:首页 > 其它

139. Word Break

2017-03-18 11:41 232 查看
public class Solution {
boolean find = false;
public boolean wordBreak(String s, List<String> wordDict) {
boolean[] f = new boolean[s.length()+1];
f[0] = true;
for(int i = 1; i <= s.length(); i++) {
for(int j = 0; j < i; j++) {
if(f[j] && wordDict.contains(s.substring(j,i))) {
f[i] = true;
break;
}
}
}

return f[s.length()];
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: