标签:bre i+1 rdb turn amp [] string highlight bool
class Solution {
public boolean wordBreak(String s, List<String> wordDict) {
boolean[] dp=new boolean[s.length()+1];
dp[0]=true;
for(int i=0;i<s.length();i++)
for(String w:wordDict)
if(i+1-w.length()>=0&&w.equals(s.substring(i+1-w.length(),i+1)))
dp[i+1]=dp[i+1]||dp[i+1-w.length()];
return dp[s.length()];
}
}
标签:bre i+1 rdb turn amp [] string highlight bool
原文地址:http://www.cnblogs.com/asuran/p/7643776.html