Skip to content

Commit c0bd451

Browse files
authored
Merge pull request #190 from Jeffzholy/fix/chapter-6-CircularLinkedList
fix: CircularLinkedList insert function
2 parents 3828b54 + 4fb2b45 commit c0bd451

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/js/data-structures/circular-linked-list.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class CircularLinkedList extends LinkedList {
3232
node.next = this.head;
3333
} else {
3434
node.next = current;
35-
current = this.getElementAt(this.size());
35+
current = this.getElementAt(this.size() - 1);
3636
// update last element
3737
this.head = node;
3838
current.next = this.head;

src/ts/data-structures/circular-linked-list.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class CircularLinkedList<T> extends LinkedList<T> {
3636
node.next = this.head;
3737
} else {
3838
node.next = current;
39-
current = this.getElementAt(this.size());
39+
current = this.getElementAt(this.size() - 1);
4040
// update last element
4141
this.head = node;
4242
current.next = this.head;

0 commit comments

Comments
 (0)