Try all possible ways to split the string and check if each segment is in the dictionary.
A string of length has ways to place dividers. Checking each segmentation is expensive.
Can you build the answer incrementally from left to right?
The trap
Try all possible ways to split the string and check if each segment is in the dictionary.
A string of length has ways to place dividers. Checking each segmentation is expensive.
Can you build the answer incrementally from left to right?