class Solution {
public:
ListNode* swapPairs(ListNode* head) {
if(head==nullptr ||head->next==nullptr)
return head;
auto tmp=swapPairs(head->next->next);
auto ret=head->next;
head->next->next=head;
head->next=tmp;
return ret;
}
};
class Solution {
public:
ListNode* swapPairs(ListNode* head) {
if(head==nullptr ||head->next==nullptr)
return head;
auto tmp=swapPairs(head->next->next);
auto ret=head->next;
head->next->next=head;
head->next=tmp;
return ret;
}
};