原题链接:Reverse String
题解:
public class Solution {
public String reverseString(String s) {
/*
Time Complexity:O(N)
Space Complexity:O(N)
*/
char[] res=s.toCharArray();
for(int i=0,j=res.length-1;i<j;i++,j--){
char temp=res[i];
res[i]=res[j];
res[j]=temp;
}
return new String(res);
}
}