Given a string and a dictionary of words, determine if the string can be segmented into dictionary words.
dp[i] = True if s[:i] can be segmented. For each position i, check all words that could END at position i.
💡 Pro tip: Understand this problem deeply — don't just memorize the code. Try explaining the approach out loud as if teaching a friend. If you can explain it simply, you truly understand it!
wordBreak('leetcode', ['leet', 'code'])
True
wordBreak('catsandog', ['cats', 'dog', 'sand', 'and', 'cat'])
False