> For the complete documentation index, see [llms.txt](https://cai-sen-se.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cai-sen-se.gitbook.io/leetcode/201-400/344.-fan-zhuan-zi-fu-chuan.md).

# 344. 反转字符串

<https://leetcode-cn.com/problems/reverse-string/>

## 解法一：

用直接逆序`s[::-1]`的方法发现行不通，还是老实交换吧：

```python
class Solution:
    def reverseString(self, s: List[str]) -> None:
        """
        Do not return anything, modify s in-place instead.
        """        
        i, j = 0, len(s)-1
        while i < j:
            s[i], s[j] = s[j], s[i]
            i += 1
            j -= 1
```
