code for LeetCode "reverse words in a string"