LeetCode 139 Word Break - Why Naive Fails

The trap

Try all possible ways to split the string and check if each segment is in the dictionary.

A string of length nn has 2n12^{n-1} ways to place dividers. Checking each segmentation is expensive.

Can you build the answer incrementally from left to right?