原地修改,简单双指针写法
class Solution {
public void reverseString(char[] s) {
//常规双指针写法
int len = s.length;
int left = 0,right = len-1;
while (left<right){
char temp = s[left];
s[left] = s[right];
s[right] = temp;
left++;
right--;
}
}
}