139. Word Break

来源:互联网 发布:桶装水软件 编辑:程序博客网 时间:2024/06/16 02:19
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()];    }}
0 0
原创粉丝点击