Reverse Words in a String — C# Coding Problem
Difficulty: easy | Category: string
Problem Description
Given an input string `s`, reverse the order of the **words**. A **word** is defined as a sequence of non-space characters. Return the words joined by a single space with no leading or trailing spaces. **Constraints:** - `1 <= s.length <= 10⁴` - `s` contains English letters, digits, and spaces - There is at least one word in `s`
Examples
Example 1
Input: s = "the sky is blue"
Output: "blue is sky the"
Example 2
Input: s = " hello world "
Output: "world hello"
Explanation: Extra spaces are removed.