139. Word Break

Practice Word Break for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return whether s can be cut into pieces so that every piece is a word from wordDict. A word may be used any number of times.

Example

s = "leetcode", wordDict = ["leet","code"]                        ->  true
s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]   ->  false

Constraints