public class Solution {
    public String reverseWords(String s){
        StringBuffer sb = new StringBuffer();
        String[] words = s.split("\\s");
        for (int i = 0; i < words.length; i++) {
            for (int j = words[i].length()-1; j >= 0; j--) {
                sb.append(words[i].charAt(j));
            }
            sb.append(" ");
        }
        return sb.toString().substring(0, sb.length()-1);
    }

    public static void main(String[] args){
        Solution solution = new Solution();
        String input = "Let's take LeetCode contest";
        String result = solution.reverseWords(input);
        System.out.println(result);
    }
}
complete problem 557