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
ServiceNow
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late August, 2026
Staff
This question was asked in the 1st round for the role of staff engineer. Duration was 1 hour and was asked to code on hackerrank.
Early August, 2026
Senior
Late June, 2026
Senior
Hello Interview Premium
Your account is free and you can post anonymously if you choose.