aboutsummaryrefslogtreecommitdiff
path: root/swap_node_pair.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'swap_node_pair.cpp')
-rw-r--r--swap_node_pair.cpp31
1 files changed, 0 insertions, 31 deletions
diff --git a/swap_node_pair.cpp b/swap_node_pair.cpp
deleted file mode 100644
index b365961..0000000
--- a/swap_node_pair.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <bits/stdc++.h>
-using namespace std;
-
-struct ListNode {
- int val;
- ListNode *next;
- ListNode() : val(0), next(nullptr) {}
- ListNode(int x) : val(x), next(nullptr) {}
- ListNode(int x, ListNode *next) : val(x), next(next) {}
-};
-
-class Solution {
-public:
- ListNode *swapPairs(ListNode *head) {
- if (!head || !head->next)
- return head;
- ListNode *temp = new ListNode;
- ListNode *prev = temp;
- ListNode *curr = head;
- while (curr && curr->next) {
- prev->next = curr->next;
- curr->next = prev->next->next;
- prev->next->next = curr;
- prev = curr;
- curr = curr->next;
- }
- return temp->next;
- }
-};
-
-int main() {}