FreeCareerPath
Build the PrimitiveMedium

Word Break

Write `word_break(s, word_dict)` returning `True` when the string can be split into a sequence of dictionary words. Words may be reused. word_break("leetcode", ["leet","code"]) -> True Greedy longest-match fails: on "aaaaab" with ["aaaa","aaa","b"] taking the longest first strands the rest. Keep a boolean per prefix — position i is reachable if some word ends there starting from a reachable position.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Word Break" are saved to your account — logging in takes a few seconds.

Word Break — FreeCareerPath