Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set tail as newNode if currentNode is the tail #1020

Closed
wants to merge 4 commits into from

Conversation

xyn22
Copy link

@xyn22 xyn22 commented Apr 8, 2023

closes #1016
closes #1004

To reproduce

  1. Populate the list normally, insert few values.
  2. call insert with rawIndex equals to last node index + 1 (exactly where new node would fit)

Expectation

this.tail should point to the last added value as it has rawIndex as previous tail + 1

Behaviour

this.tail points to the previous tail.

Fix

If currentNode is the tail then newNode should be the new tail, as in this scenario currentNode will have newNode as its next

vrutikjadav added a commit to vrutikjadav/javascript-algorithms that referenced this pull request Jan 23, 2024
@xyn22 xyn22 closed this Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant