← 返回 bytedance 的题目列表Reverse Words in a String
类型:online_judge
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Input: A string s.
Output: Return a string with the order of characters reversed in each word.
Example 1:
Input: "the sky is blue"
Output: "blue is sky the"
Example 2:
Input: " hello world "
Output: "world hello"
Explanation: The input string may contain multiple spaces, but the output should not contain leading or trailing spaces excluding spaces between words.
Constraints: 1 <= s.length <= 10^4
Example
Input
the sky is blue