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 }

猜你喜欢

转载自www.cnblogs.com/sheepcore/p/12396085.html
今日推荐