输入:[“h”,“e”,“l”,“l”,“o”]
输出:[“o”,“l”,“l”,“e”,“h”]
public void reverseString(char[] s) {
int length = s.length - 1;
int half = s.length >> 1;
for (int i = 0; i < half; i++) {
char pre = s[i];
s[i] = s[length - i];
s[length - i] = pre;
}
}