Intermediate Level
Implement the method reverseWords that reverses the order of words in a string.
Return a string where words appear in reverse order while each word keeps its own character order.
The task is designed to test careful handling of edge cases, not only the most common input.
- Use a single space between words in the output.
- Ignore empty pieces created by repeated spaces.
- Do not reverse characters inside each word.
Split the input into real words, discard empty pieces, then join the words from right to left.