139. Word Break
problem description
Input: s = "leetcode", wordDict = ["leet", "code"]
Output: true
Explanation: Return true because "leetcode" can be segmented as "leet code".Input: s = "applepenapple", wordDict = ["apple", "pen"]
Output: true
Explanation: Return true because "applepenapple" can be segmented as "apple pen apple".
Note that you are allowed to reuse a dictionary word.Input: s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]
Output: falsealgorithm thought
code
algorithm analysis
Last updated