344. Reverse String
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
//把字符串进行翻转 利用i、j两个数进行标记下标
public class Solution {
public String reverseString(String s) {
char[] a=s.toCharArray();
int i=0;
int j=s.length()-1;
while(i<=j){
char temp=a[j];
a[j]=a[i];
a[i]=temp;
i++;
j--;
}
return new String(a);
}
}