From 7e171a3d2fe767733e1b0e2467e019c6571c34aa Mon Sep 17 00:00:00 2001 From: Tiansheng Sui Date: Mon, 17 May 2021 17:11:23 -0700 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A00344.=E5=8F=8D=E8=BD=AC?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2Python3=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0344.反转字符串.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/problems/0344.反转字符串.md b/problems/0344.反转字符串.md index b4c843b7..67d0227e 100644 --- a/problems/0344.反转字符串.md +++ b/problems/0344.反转字符串.md @@ -157,7 +157,18 @@ class Solution { ``` Python: - +```python3 +class Solution: + def reverseString(self, s: List[str]) -> None: + """ + Do not return anything, modify s in-place instead. + """ + left, right = 0, len(s) - 1 + while(left < right): + s[left], s[right] = s[right], s[left] + left += 1 + right -= 1 +``` Go: ```Go