Recursive Python solution


  • 1
    S
    if head == None or head.next == None:
        return head
    temp = head.next
    head.next = self.swapPairs(head.next.next)
    temp.next = head
    return temp
    
    

Log in to reply
 

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