aboutsummaryrefslogtreecommitdiff
path: root/remove_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'remove_node.cpp')
-rw-r--r--remove_node.cpp31
1 files changed, 0 insertions, 31 deletions
diff --git a/remove_node.cpp b/remove_node.cpp
deleted file mode 100644
index 1f79374..0000000
--- a/remove_node.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <bits/stdc++.h>
-#include <cstddef>
-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 *removeNthFromEnd(ListNode *head, int n) {
- ListNode *temp = head;
- for (int i = 0; i < n; i++)
- temp = temp->next;
- if (temp == NULL)
- return head->next;
- ListNode *curr = head;
- while (temp->next) {
- temp = temp->next;
- curr = curr->next;
- }
- curr->next = curr->next->next;
- return head;
- }
-};
-
-int main() {}