一、题目描述
二、解法
class Solution { public void reverseString(char[] s) { if (s == null || s.length == 0) return; int l = 0, r = s.length - 1; while (l < r) { swap(s, l, r); l ++; r --; } } private void swap(char[] chars, int a, int b) { char temp = chars[a]; chars[a] = chars[b]; chars[b] = temp; } }