DEV Community

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

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 😃