DEV Community

Discussion on: Solution: Remove Nth Node From End of List

Collapse
 
seanpgallivan profile image
seanpgallivan

I'm not sure I understand the question. The head pointer is never overwritten, so it always represents the start of the entire linked list. That doesn't change when the node deletion occurs.

Collapse
 
chandub15 profile image
chandub15 • Edited

The function returns head at the end which has the list after the deleting the required node. How does this happen when we aren't updating head ?

Thread Thread
 
seanpgallivan profile image
seanpgallivan

The variable head just contains a pointer to the start of the linked list. It doesn't contain the entire linked list. So any changes made to the nodes of the list and their connections will affect a traversal of the list starting at head.

Thread Thread
 
chandub15 profile image
chandub15

Got it. Thanks for your reply 😃