Recursive solution for 2.2.8 Swap Nodes in Pairs
Yobretaw opened this issue · 0 comments
Yobretaw commented
ListNode* swapPairs(ListNode *head) {
if(head == NULL || head->next == NULL)
return head;
ListNode *next = head->next;
ListNode *temp = next->next;
next->next = head;
head->next = swapPairs(temp);
return next;
}