Skip to content

Commit f4a2006

Browse files
committed
trekhleb#1020 updating insert at Head part
1 parent 76617fa commit f4a2006

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/data-structures/linked-list/LinkedList.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ export default class LinkedList {
8080
this.tail.next = newNode;
8181
this.tail = newNode;
8282
} else {
83-
this.head = newNode;
84-
this.tail = newNode;
83+
// this.head = newNode;
84+
// this.tail = newNode;
85+
newNode.next = this.head;
86+
newNode = this.head;
8587
}
8688
}
8789
}

0 commit comments

Comments
 (0)