Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
  • src/_DataStructures_/LinkedList

1 file changed

+2
-7
lines changed

‎src/_DataStructures_/LinkedList/index.js‎

Lines changed: 2 additions & 7 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /