Can you explain how head holds the new list after deletion. slow holds remaining values of head after n from beginning and after we delete the nth value from slow using slow.next=slow.next.next; , how does head hold exact list after deletion?
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.
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.
Can you explain how head holds the new list after deletion. slow holds remaining values of head after n from beginning and after we delete the nth value from slow using slow.next=slow.next.next; , how does head hold exact list after deletion?
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.
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 😃