0139. Word Break
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:** falseac1: DP
ac2: DFS + Memorization
Last updated