python using re


  • 0
    W
    class Solution(object):
        def reverseStr(self, s, k):
            pat = re.compile('[a-z]{1,%d}' % (2 * k))
            splited = re.findall(pat, s)
            return ''.join(i[k-1::-1] + i[k:] for i in splited)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.