Search
⌘K

Leetcode 140. Word Break II

Given a string s and a word dictionary, return all possible sentences formed by inserting spaces so every token is a dictionary word — i.e., enumerate all valid segmentations. The challenge is to generate all combinations efficiently by exploring prefixes and using memoization/DP to avoid exponential rework and prune impossible splits.

Asked at:

Bloomberg

Bloomberg

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late October, 2025

Bloomberg

Bloomberg

Junior

Early February, 2025

Meta

Mid-level

Comments

Your account is free and you can post anonymously if you choose.