Skip to content

Commit

Permalink
fix: CircularLinkedList insert function
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-zhenz committed May 11, 2022
1 parent 3828b54 commit 4fb2b45
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/data-structures/circular-linked-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class CircularLinkedList extends LinkedList {
node.next = this.head;
} else {
node.next = current;
current = this.getElementAt(this.size());
current = this.getElementAt(this.size() - 1);
// update last element
this.head = node;
current.next = this.head;
Expand Down
2 changes: 1 addition & 1 deletion src/ts/data-structures/circular-linked-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class CircularLinkedList<T> extends LinkedList<T> {
node.next = this.head;
} else {
node.next = current;
current = this.getElementAt(this.size());
current = this.getElementAt(this.size() - 1);
// update last element
this.head = node;
current.next = this.head;
Expand Down

0 comments on commit 4fb2b45

Please sign in to comment.