LeetCode-344 Posted on 2020-07-29 Edited on 2025-02-13 In LeetCode 题目 结果 代码123456789101112class Solution { public void reverseString(char[] s) { int left = 0, right = s.length - 1; while (left < right) { char tmp = s[left]; s[left] = s[right]; s[right] = tmp; left++; right--; } }} 复杂度时间复杂度:O(n) 空间复杂度:O(1)