leetcode 24 Swap Nodes in Pairs

class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        if (!head || !head->next) return head;
        ListNode *t = head->next;
        head->next = swapPairs(head->next->next);
        t->next = head;
        return t;
    }
};
原文地址:https://www.cnblogs.com/wangkun1993/p/6388174.html