// Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.

// For example, given
// s = "leetcode",
// dict = ["leet", "code"].

// Return true because "leetcode" can be segmented as "leet code".

public class Solution {
    public boolean wordBreak(String s, Set<String> dict) {
    	if(s.length() < 1) return false;

        boolean[] splitPoint = new boolean[s.length() + 1];
        splitPoint[0] = true;

        for(int i = 0; i <= s.length(); i++){
        	for(int j = 0; j < i; j++){
        		String subString = s.substring(j, i);
        		if(splitPoint[j] && dict.contains(subString)){
        			splitPoint[i] = true;
        			break;
        		}
        	}
        } 

        return splitPoint[s.length()];
    }
}
@@ -814,8 +814,1041 @@
 %0A    %7D%0A%7D
+%0A%0A%0A // public boolean wordBreak(String s, Set%3CString%3E dict) %7B%0A //        // recursive approach: in each recursion, iterate over%0A //        // all dict words, if starting from current index, the substring%0A //        // is same as dict word, go down to next level recursion, if it %0A //        // returns true then current recursion also returns true.%0A //        return dfsHelper(s, dict, 0);%0A //    %7D%0A    %0A //    public boolean dfsHelper(String s, Set%3CString%3E dict, int start) %7B%0A //        if (start == s.length()) %7B%0A //            return true;%0A //        %7D%0A        %0A //        for (String word : dict) %7B%0A //            int wordLen = word.length();%0A //            int index = wordLen + start;%0A //            if (index %3E s.length()) %7B%0A //                continue;%0A //            %7D%0A            %0A //            if (s.substring(start, index).equals(word)) %7B%0A //                if (dfsHelper(s, dict, index)) %7B%0A //                    return true;%0A //                %7D%0A //            %7D%0A //        %7D%0A        %0A //        return false;%0A //    %7D

add recursive solution for word-break, though TLE