Golang recursive 0ms


  • 0
    R
    func swapPairs(head *ListNode) *ListNode {
        if head == nil || head.Next == nil {
            return head;
        }
        res := head.Next
        head.Next = swapPairs(res.Next)
        res.Next = head
        return res
    }
    

Log in to reply
 

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