Python solution using 36ms with simple method

  • 4

    class Solution(object):

    def swapPairs(self, head):
        if not head or not
            return head
        first,second = head,
        third =
        head = second = first = self.swapPairs(third)
        return head

Log in to reply

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