Solve reverse words in a string