Given a singly linked list, remove the nth node from the end. Try to do it in one pass.
Use two pointers with a gap of exactly n between them. When the second pointer reaches NULL, remove the node at the first pointer.
Here is the code:
| |
Given a singly linked list, remove the nth node from the end. Try to do it in one pass.
Use two pointers with a gap of exactly n between them. When the second pointer reaches NULL, remove the node at the first pointer.
Here is the code:
| |