541-Reverse-String-Ii

Sat 17 May 2025

https://leetcode.com/problems/reverse-string-ii

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def reverseStr(self, s: str, k: int) -> str:
    return s[:k][::-1] + s[k:2 * k] + self.reverseStr(s[2 * k:], k) if s else ""
new Solution().reverseStr()

Score: 5

Category: leetcode