We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9084503 commit 346d9f0Copy full SHA for 346d9f0
src/_DataStructures_/LinkedList/index.js
@@ -126,12 +126,7 @@ class LinkedList {
126
return null;
127
}
128
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;
+ return this.removeFromBeginning();
135
136
137
if (index >= this.size - 1) {
@@ -147,7 +142,7 @@ class LinkedList {
147
142
address = address.next;
148
143
count -= 1;
149
144
150
- const node = previous.next;
145
+ const node = address;
151
146
previous.next = address.next;
152
this.size -= 1;
153
0 commit comments