344. 反转字符串
双指针法
class Solution {
public void reverseString(char[] s) {
/**
* 双指针遍历
*/
int left = 0;
int right = s.length - 1;
char c;
while (left < right){
c = s[left];
s[left++] = s[right];
s[right++] = c;
}
}
}
/**
* 时间复杂度 O(n)
* 空间复杂度 O(1)
*/
https://leetcode-cn.com/problems/reverse-string/