We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d22464f + 27585bd commit 2d6fdc8Copy full SHA for 2d6fdc8
problems/0541.反转字符串II.md
@@ -282,7 +282,7 @@ class Solution:
282
return ''.join(res)
283
```
284
285
-### Python3 (v2):
+#### Python3 (v2):
286
287
```python
288
class Solution:
@@ -297,6 +297,21 @@ class Solution:
297
return s
298
299
300
+#### Python3 (v3):
301
+
302
+```python
303
+class Solution:
304
+ def reverseStr(self, s: str, k: int) -> str:
305
+ i = 0
306
+ chars = list(s)
307
308
+ while i < len(chars):
309
+ chars[i:i + k] = chars[i:i + k][::-1] # 反转后,更改原值为反转后值
310
+ i += k * 2
311
312
+ return ''.join(chars)
313
+```
314
315
### Go:
316
317
```go
0 commit comments