算法随想录算法训练营第四十天| 139.单词拆分

 139.单词拆分 

这题没有理解

 public static boolean wordBreak(String s, List wordDict) {
        boolean[] dp = new boolean[s.length() + 1];
        dp[0] = true;
        for (int i = 0; i <= s.length(); i++) {
            for (String word : wordDict) {
                int len = word.length();
                if(i> len&& dp[i-len] == true && word.equals(s.substring(i - len, i))){
                    dp[i] = true;
                    break;
                }
            }
        }
        return dp[s.length()];
    }

你可能感兴趣的:(算法)