Word Break

Medium · Dynamic Programming · about 25 minutes

Asked at Meta, Amazon, Google, Bloomberg, Citadel.

Decide whether the string s can be cut into pieces so that every piece is a word from wordDict. Words can be used more than once.

Example: s = "applepie", wordDict = ["apple", "pie"] → true ("apple" + "pie").

Related guides