Skip to content

Conversation

@EMU1337X
Copy link

Python:

class Solution(object):
def reverseStr(self, s, k):
"""
:type s: str
:type k: int
:rtype: str
"""
s = ' '.join(s)
s = s.split(' ')
def reverse(ss):
l = len(ss) - 1
for i in range(int(len(ss) / 2)):
ss[i], ss[l - i] = ss[l - i], ss[i]
return ss

    for i in range(0, len(s), 2 * k):
        if i + k > len(s) - 1:
            s[i:] = reverse(s[i:])
        else:
            s[i:i + k] = reverse(s[i:i + k])
    s = ''.join(s)
    return s

@EMU1337X EMU1337X deleted the patch-2 branch May 13, 2021 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants