Deviopath › JavaScript

Word Break

Hard · Dynamic Programming

Write a function wordBreak that returns true if the string s can be split into a sequence of one or more words from the array dict. A word can be used many times. An empty string returns true.

Make it efficient: trying every split blindly is too slow for long strings.

Next: Longest Common Subsequence