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;
    }
};
posted @ 2017-02-10 22:38  王坤1993  阅读(132)  评论(0编辑  收藏  举报