@@ -0,0 +1,1072 @@
+package leetcode;%0A%0A/**%0A * https://leetcode.com/problems/reverse-words-in-a-string-iii/%0A */%0Apublic class Problem557 %7B%0A    public String reverseWords(String s) %7B%0A        StringBuilder sb = new StringBuilder();%0A        String%5B%5D split = s.split(%22 %22);%0A        for (int i = 0; i %3C split.length; i++) %7B%0A            if (i == 0) %7B%0A                sb.append(reverse(split%5Bi%5D.toCharArray()));%0A            %7D else %7B%0A                sb.append(%22 %22 + reverse(split%5Bi%5D.toCharArray()));%0A            %7D%0A        %7D%0A        return sb.toString();%0A    %7D%0A%0A    private static String reverse(char%5B%5D chars) %7B%0A        for (int i = 0, j = chars.length - 1; i %3C j; i++, j--) %7B%0A            char tmp = chars%5Bi%5D;%0A            chars%5Bi%5D = chars%5Bj%5D;%0A            chars%5Bj%5D = tmp;%0A        %7D%0A        return new String(chars);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem557 prob = new Problem557();%0A        System.out.println(prob.reverseWords(%22Let's take LeetCode contest%22));%0A        System.out.println(prob.reverseWords(%22Hello%22));%0A        System.out.println(prob.reverseWords(%22%22));%0A    %7D%0A%7D%0A

Solve problem 557