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.
Example 1:
Input: Let's take the LeetCode contest. Output: 's'teL ekat edoCteeL tsetnoc'
Note: In the string, each word is separated by single space and there will not be any extra space in the string.
public class Solution { public String reverseWords(String s) { char[] c = s.toCharArray(); int pos = 0; for(int i=0;i This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:
Original author:Jake Tao,source:"LeetCode – 557. Reverse Words in a String III"