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 ?
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.
Got it. Thanks for your reply 😃
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 ?
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.
Got it. Thanks for your reply 😃