Skip to content

Commit 346d9f0

Browse files
committed
fix: requested changes for LL removeAt()
1 parent 9084503 commit 346d9f0

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/_DataStructures_/LinkedList/index.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,7 @@ class LinkedList {
126126
return null;
127127
}
128128
if (index === 0) {
129-
const node = this.head;
130-
this.head = this.head.next;
131-
this.size -= 1;
132-
// set the next of the node null
133-
node.next = null;
134-
return node;
129+
return this.removeFromBeginning();
135130
}
136131

137132
if (index >= this.size - 1) {
@@ -147,7 +142,7 @@ class LinkedList {
147142
address = address.next;
148143
count -= 1;
149144
}
150-
const node = previous.next;
145+
const node = address;
151146
previous.next = address.next;
152147
this.size -= 1;
153148

0 commit comments

Comments
 (0)