Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
java代码实现
public class Solution {
public String reverseString(String s) {
StringBuffer tmp=new StringBuffer("");
int tail=s.length()-1;
for(int i=tail;i>=0;i--){
tmp.append(s.charAt(i));
}
return tmp.toString();
}
}