Advancedcoding Verified
Given a string and a dictionary of words, return every way to insert spaces so the string becomes a sentence of dictionary words (Word Break II).
ReportedSource: GeeksforGeeks interview experience: Amazon SDE-II
Quick answerFree
DFS from each start index, try every dictionary word that matches, memoise results per index (or use a Trie for matching). Output can be exponential; pre-check feasibility with the boolean Word Break DP.
Detailed answer· ~110 words
ProUnlock the full answer with Pro
Get a ~110-word model answer and a runnable reference solution, plus 82 more DSA questions.
Reference solution· runs in the browser sandbox
ProUnlock with Pro
+ 82 more DSA questions in Pro, each with the full answer.