题目描述:
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
我的AC代码:
public class Solution {
public String reverseString(String s) {
char[] a=s.toCharArray();
char[] temp=new char[a.length];
int j=0;
for(int i=a.length-1;i>=0;i--){
temp[j]=a[i];
j++;
}
return String.valueOf(temp);
}
}