python concise recursive

  • 0
    class Solution(object):
        def reverseKGroup(self, head, k):
            if head:
                node = head
                for _ in range(k - 1):
                    node =
                    if not node:
                        return head
                prev = self.reverseKGroup(, k)
                while prev is not node:
                    prev,, head = head, prev,
                return prev

Log in to reply

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