Steward
分享是一種喜悅、更是一種幸福
程式語言 - LeetCode - C - 24. Swap Nodes in Pairs
參考資訊:
https://www.cnblogs.com/grandyang/p/4441680.html
題目:

解答:
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* swapPairs(struct ListNode* head)
{
if (!head || !head->next) {
return head;
}
struct ListNode* t = head->next;
head->next = swapPairs(head->next->next);
t->next = head;
return t;
}