557. Reverse Words in a String III 反轉字串裡的單字
❀ Origin
Problem
Given a string,
you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Note
- In the string, each word is separated by single space and there will not be any extra space in the string.
Example
1 | Input: "Let's take LeetCode contest" |
❀ 翻譯
問題
給定一個字串,
你必須倒轉每個單字裡的字母的順序, 同時保留空格和原始句子的順單字順序.
注意
- 在字串裡, 每個單字都會用一個空白來隔開, 而且單字裡不會存在額外的空白.
❀ Solution
JavaScript
1 | /** |