Word Break II
A hard-tier problem at 54% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Dropbox and 11 others.
Word Break II is a hard problem that hits candidates in live assessments at Dropbox, TikTok, Amazon, Uber, and other tier-one companies. You're given a string and a word dictionary, and you need to return every possible sentence where each word exists in the dict. The acceptance rate hovers around 53%, which means roughly half the people who attempt it blank or timeout. This isn't a pattern most candidates have drilled. If this problem lands in your live OA and you freeze on the approach, StealthCoder solves it invisibly during screen share, surfacing a working solution in seconds.
Companies that ask "Word Break II"
Word Break II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe trap is thinking this is just word break one with extra steps. It's not. You need to generate all valid segmentations, not just confirm one exists. Most candidates start with naive recursion and hit exponential blowup. The trick combines backtracking to explore all valid paths with memoization on subproblems to cut redundant work. Some also use a Trie to speed word lookup, though a hash table often suffices. The core insight: build solutions bottom-up from the end of the string, cache results for substrings you've already solved, and only recurse on branches that lead to valid segmentations. Dynamic programming handles existence; backtracking with memoization handles enumeration. If you haven't internalized this pattern before your OA, StealthCoder is the hedge that buys you the solution without derailing your other problems.
Pattern tags
You know the problem.
Make sure you actually pass it.
Word Break II recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Word Break II interview FAQ
Why is Word Break II so much harder than Word Break I?+
Word Break I asks if a solution exists (yes/no). Word Break II asks you to return all solutions. Existence checks can use simple DP. Enumeration requires backtracking to explore every valid branch, which is exponential in the worst case. You can't just return early once you find one answer.
Is this still asked at FAANG?+
Yes. It shows up at Amazon, Dropbox, Uber, TikTok, and others. It's not the most common hard string problem, but it's frequent enough that candidates interviewing at those companies should be ready for it or have a hedge.
What's the main optimization trick?+
Memoization on substrings. Cache the list of valid segmentations for each suffix of the input string. When you recurse on the same substring again, return the cached result instead of recomputing. This collapses exponential time into polynomial time in many cases.
Should I use a Trie or a Hash Table?+
Hash Table is simpler and sufficient for most inputs. Trie is faster if the dictionary is huge or has long common prefixes. For a live assessment, hash table is the safer bet unless the problem explicitly hints at a large dictionary or you're hitting time limits.
How does this relate to the other topics listed?+
Backtracking handles enumeration of all valid paths. Memoization caches subproblems to avoid recomputation. Hash Table or Trie speeds word lookup. Dynamic Programming insight tells you which substrings can be segmented. All three concepts work together. It's a hard problem because it combines multiple techniques.
Want the actual problem statement? View "Word Break II" on LeetCode →