TheAlgorithms-C/leetcode/src/24.c
2020-05-29 20:23:24 +00:00

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;
}