Given a string s, reverse the order of words. Multiple spaces between words should be reduced to a single space. Leading/trailing spaces should be removed.
Split by spaces, filter empty strings, reverse the list, join with single space.
- Use built-in split or manual two-pointer approach.
- Trim the string, split on whitespace (handles multiple spaces).
- Reverse the resulting array.
- Join with single space.
- Time Complexity: O(N)
- Space Complexity: O(N)