We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5105898 commit 97926b1Copy full SHA for 97926b1
src/data-structures/linked-list/LinkedList.js
@@ -128,13 +128,17 @@ export default class LinkedList {
128
*/
129
deleteTail() {
130
const deletedTail = this.tail;
131
+
132
if (this.head === this.tail) {
133
// There is only one node in linked list.
134
this.head = null;
135
this.tail = null;
136
137
return deletedTail;
138
}
139
140
+ // If there are many nodes in linked list...
141
142
// Rewind to the last node and delete "next" link for the node before the last one.
143
let currentNode = this.head;
144
while (currentNode.next) {
0 commit comments