private boolean wordBreakDP(String s, Set<String> dict) {
            boolean[] dp = new boolean[s.length() + 1];
            dp[0] = true;

            for (int i = 1; i <= s.length(); i++) {
                dp[i] = false;
                for (String word : dict) {
                    if (word.length() > i) {
                        continue;
                    } else {
                        if (dp[i - word.length()] == true
                                && word.equals(s.substring(i - word.length(), i))) {
                            dp[i] = true;
                            break;
                        }
                    }
                }
            }

            return dp[s.length()];
        }