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; } };
leetcode 24 Swap Nodes in Pairs
原文:http://www.cnblogs.com/wangkun1993/p/6388174.html