mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
10 lines
228 B
C
10 lines
228 B
C
struct ListNode *swapPairs(struct ListNode *head)
|
|
{
|
|
if (!head || !head->next)
|
|
return head;
|
|
struct ListNode *tmp = head->next;
|
|
head->next = swapPairs(head->next->next);
|
|
tmp->next = head;
|
|
return tmp;
|
|
}
|