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