-
Notifications
You must be signed in to change notification settings - Fork 935
Closed
Description
When there is only one Node , this linkedlist is wrong.
removeFirst() {
const head = this.first;
if (head) {
this.first = head.next;
if (this.first) {
this.first.previous = null;
}
this.size -= 1;
} else {
this.last = null;
}
return head && head.value;
}The following code is correct.
removeFirst() {
const head = this.first;
if (head) {
this.first = head.next;
if (this.first) {
this.first.previous = null;
}
else {
this.last = null;
}
this.size -= 1;
}
return head && head.value;
}Metadata
Metadata
Assignees
Labels
No labels