标签:length ret boolean blog solution tco word == span
class Solution { public boolean wordBreak(String s, List<String> wordDict) { if (s == null || s.length() == 0) { return false; } boolean[] canBreak = new boolean[s.length() + 1]; canBreak[0] = true; for (int i = 1; i <= s.length(); i++) { for (int j = i - 1; j >= 0; j--) { if (canBreak[j] && wordDict.contains(s.substring(j, i))) { canBreak[i] = true; break; } } } return canBreak[s.length()]; } }
标签:length ret boolean blog solution tco word == span
原文地址:http://www.cnblogs.com/shuashuashua/p/7403785.html