类型:字符串
-
- 反转字符串 💚
https://leetcode-cn.com/problems/reverse-string/
❓ 原地翻转字符串。
💡 双指针
class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ length = len(s) for i in range(length // 2): if s[i] == s[length - 1 - i]: continue s[i], s[length - 1 - i] = s[length - 1 - i], s[i]时间复杂度:O(n),空间复杂度:O(1)