Practice/Meta/Leetcode 557. Reverse Words in a String III
CodingMust
Given a string containing multiple words separated by single spaces, reverse the character order within each individual word while keeping the words in their original positions. The string will contain only printable ASCII characters and will not have leading or trailing spaces.
Example 1:
Input: s = "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Explanation: Each word has its characters reversed: "Let's" becomes "s'teL", "take" becomes "ekat", etc.
Example 2:
Input: s = "Hello" Output: "olleH" Explanation: With only one word, we simply reverse its characters.
Example 3:
Input: s = "I love programming" Output: "I evol gnimmargorp" Explanation: The single character word "I" stays as "I", while longer words are reversed.