mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
set tail as newNode if currentNode is the tail
This commit is contained in:
parent
bbbfd32a45
commit
019c07e9e3
@ -75,6 +75,9 @@ export default class LinkedList {
|
||||
if (currentNode) {
|
||||
newNode.next = currentNode.next;
|
||||
currentNode.next = newNode;
|
||||
if (this.tail === currentNode) {
|
||||
this.tail = newNode;
|
||||
}
|
||||
} else {
|
||||
if (this.tail) {
|
||||
this.tail.next = newNode;
|
||||
|
Loading…
Reference in New Issue
Block a user