Google has a video coaching job candidates on whiteboarding.
In it, they provide a sample problem (given a string of two words without spaces and a dictionary of valid words, return a string with the same words appropriately separated by a space).
They also provide a sample solution and one of the coaches explains that one easy way to improve the solution is to make it not a brute-force solution. See a few seconds into the video here:
I don’t understand how this solution can be improved, including how it can be improved by somehow not making it not “brute force”.
Can anyone explain?