牛客题霸--反转字符串题解
反转字符串
http://www.nowcoder.com/questionTerminal/c3a6afee325e472386a1c4eb1ef987f3
反转字符串
https://www.nowcoder.com/practice/c3a6afee325e472386a1c4eb1ef987f3
public String solve (String str) {
// write code here
// write code here
StringBuilder s = new StringBuilder();
for (int i = str.length() - 1; i >= 0; i--) {
s.append(str.charAt(i));
}
return s.toString();
}
反向遍历插入StringBuilder就可以了。