LeetCode-557 Reverse Words in a String III Solution (with Java)

1. Description:

2.Solutions:

 1 /**
 2  * Created by sheepcore on 2019-02-24
 3  */
 4 class Solution {
 5     public String reverseWords(String s) {
 6         String[] splitStr = s.split(" "); 
 7         String temp = "";
 8         for (String str : splitStr) 
 9             temp += new StringBuffer(str).reverse().toString() + " ";
10         return temp.substring(0, temp.length() - 1);
11     }
12 }

 

posted @ 2020-03-02 16:00  SheepCore  阅读(259)  评论(0编辑  收藏  举报