I have been given a corrupted string with spaces present at wrong places and a dictionary containing the correct words. The challenge is to construct the original string using the dictionary.
For example :
Dictionary : ["how","are","you"]
Corrupted String : ho ware y ou
Original String : how are you
I am thinking of a recursive approach since every character there are 2 possibilities, it can be a new word or a part of the previous word. Am I going in the right direction? Is there a better approach for this problem?