题解 | #翻转单词序列#
翻转单词序列
http://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3
public class Solution {
public String ReverseSentence(String str) {
if("".equals(str) || str.length() == 0) return "";
String [] split = str.split(" ");
String temp = "";
for(int i = 0;i < split.length;i++){
temp = temp + split[split.length - 1 - i];
if(i != split.length - 1){
temp = temp + " ";
}
}
return temp;
}
}