Skip to content

Commit 379bba9

Browse files
541_Reverse_String_II
1 parent 00daed7 commit 379bba9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

541_Reverse_String_II.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def reverseStr(self, s, k):
3+
"""
4+
:type s: str
5+
:type k: int
6+
:rtype: str
7+
"""
8+
new_s = ''
9+
for i in range(0, len(s), 2 * k):
10+
new_s += s[i:i+k][::-1]
11+
new_s += s[i+k:i+2*k]
12+
return (new_s)

0 commit comments

Comments
 (0)