package com.fishercoder.solutions;

/**
 * 557. Reverse Words in a String III
 *
 * 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 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 _557 {

    public String reverseWords(String s) {
        StringBuilder stringBuilder = new StringBuilder();
        StringBuilder sbUtils = new StringBuilder();
        for (String word : s.split(" ")) {
            sbUtils.setLength(0);
            sbUtils.append(word);
            stringBuilder.append(sbUtils.reverse().toString());
            stringBuilder.append(" ");
        }
        stringBuilder.setLength(stringBuilder.length() - 1);
        return stringBuilder.toString();
    }

}

@@ -455,16 +455,56 @@
 _557 %7B%0A%0A
+    public static class Solution1 %7B%0A    
     publ
@@ -534,24 +534,28 @@
 String s) %7B%0A
+    
         Stri
@@ -601,32 +601,36 @@
 lder();%0A        
+ 
+   
 StringBuilder sb
@@ -666,16 +666,20 @@
         
+    
 for (Str
@@ -701,24 +701,28 @@
 lit(%22 %22)) %7B%0A
+    
             
@@ -747,32 +747,36 @@
 0);%0A            
+    
 sbUtils.append(w
@@ -781,16 +781,20 @@
 (word);%0A
+    
         
@@ -853,32 +853,36 @@
 ));%0A            
+   
+ 
 stringBuilder.ap
@@ -900,18 +900,26 @@
         
-%7D%0A
+    %7D%0A    
         
@@ -979,16 +979,20 @@
         
+  
+  
 return s
@@ -1020,13 +1020,22 @@
 ();%0A    
+    %7D%0A    
 %7D
-%0A
 %0A%7D%0A

refactor 557