class Solution {
public:
ListNode* swapPairs(ListNode* head) {
if(head==nullptr || head->next==nullptr)
return head;
ListNode* tmp=head->next;
ListNode* node=tmp->next;
tmp->next=head;
head->next=swapPairs(node);
return tmp;
}
};
Leecode 24. 两两交换链表中的节点 链表
最新推荐文章于 2024-06-14 11:15:55 发布