两两交换链表中的节点

/**
 * Definition for singly-linked list.
 * type ListNode struct {
 *     Val int
 *     Next *ListNode
 * }
 */
func swapPairs(head *ListNode) *ListNode {
    dummy := &ListNode{ Next: head }
    cur := dummy
    for curr.Next != nil && curr.Next.Next != nil {
        next := cur.Next
        cur.Next = next.Next
        next.Next = cur.Next.Next
        cur.Next.Next = next
        cur = next
    }
 
    return dummy.Next
}