Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 97926b1

Browse files
committed
Add comments to Linked List code.
1 parent 5105898 commit 97926b1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ export default class LinkedList {
128128
*/
129129
deleteTail() {
130130
const deletedTail = this.tail;
131+
131132
if (this.head === this.tail) {
132133
// There is only one node in linked list.
133134
this.head = null;
134135
this.tail = null;
135136

136137
return deletedTail;
137138
}
139+
140+
// If there are many nodes in linked list...
141+
138142
// Rewind to the last node and delete "next" link for the node before the last one.
139143
let currentNode = this.head;
140144
while (currentNode.next) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /