Skip to content

Commit

Permalink
Update remove-element.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kounkou authored Nov 27, 2024
1 parent bd097d7 commit 21b336a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions logic/linked-list/remove-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var question = [
{
id: "Remove element",
category: "Linked List",
placeHolderCpp: `struct ListNode {\n int data;\n ListNode* next;\n};\n\nListNode* removeElements(ListNode* head, int val) {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`,
placeHolderCpp: `struct ListNode {\n int data;\n ListNode* next;\n};\n\nListNode* removeElements(ListNode* head, int t) {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`,
placeHolderGo: `func removeElements(head *ListNode, val int) *ListNode {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`,
difficulty: "Medium",
question: "Remove all elements from a linked list that have a specific value.",
Expand All @@ -13,14 +13,14 @@ var question = [
ListNode(int v) : val(v), next(nullptr) {}
};
ListNode* removeElements(ListNode* head, int v) {
ListNode* removeElements(ListNode* head, int t) {
ListNode* dummy = new ListNode(0);
dummy->next = head;
ListNode* prev = dummy;
ListNode* curr = head;
while (curr != nullptr) {
if (curr->val == v) {
if (curr->val == t) {
prev->next = curr->next;
} else {
prev = curr;
Expand Down

0 comments on commit 21b336a

Please sign in to comment.