Back to exercises

Remove Nth Node From End

Use a dummy node, move the fast pointer n steps ahead, then move both fast and slow together until fast reaches the end. The slow pointer will be just before the node to remove.

Coding Exercises Medium O(n)

Remove Nth Node From End

Use a dummy node, move the fast pointer n steps ahead, then move both fast and slow together until fast reaches the end. The slow pointer will be just before the node to remove.

Remove the nth node from the end of a linked list and return the head.