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 6e897a0 commit 5105898Copy full SHA for 5105898
src/data-structures/linked-list/LinkedList.js
@@ -127,18 +127,14 @@ export default class LinkedList {
127
* @return {LinkedListNode}
128
*/
129
deleteTail() {
130
+ const deletedTail = this.tail;
131
if (this.head === this.tail) {
132
// There is only one node in linked list.
- const deletedTail = this.tail;
133
this.head = null;
134
this.tail = null;
135
136
return deletedTail;
137
}
138
-
139
- // If there are many nodes in linked list...
140
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