class Solution { public List<String> wordBreak(String s, List<String> wordDict) { List<String> res = new ArrayList<>(); int max = 0, min = Integer.MAX_VALUE; Set<String> set = new HashSet<>(); for (String word : wordDic…
Word Break II Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "catsanddog", dict = ["cat",…
Word Break II Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "catsanddog", dict = ["cat",…