This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

28
23/08/24.cpp Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include "lists.h"
class Q24 {
public:
ListNode *swapPairs(ListNode *head) {
if (!head || !head->next) {
return head;
}
ListNode *p1;
ListNode *p2;
p1 = head;
p2 = head->next;
while (!p2){
p1->next = p2->next;
p2->next = p1;
if(!p1->next){
return head;
}
p1 = p1->next;
p2 = p1->next;
}
return head;
}
};