Python | Leetcode Python题解之第541题反转字符串II
题目:
题解:
class Solution:def reverseStr(self, s: str, k: int) -> str:t = list(s)for i in range(0, len(t), 2 * k):t[i: i + k] = reversed(t[i: i + k])return "".join(t)
题目:
题解:
class Solution:def reverseStr(self, s: str, k: int) -> str:t = list(s)for i in range(0, len(t), 2 * k):t[i: i + k] = reversed(t[i: i + k])return "".join(t)