One line Python

  • 0
    class Solution(object):
        def reverseStr(self, s, k):
            :type s: str
            :type k: int
            :rtype: str
            return "".join(s[i: i + k][:: -1] if index % 2 == 0 else s[i: i + k] for index, i in enumerate(range(0, len(s), k)))

Log in to reply

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