Remove Nth Node From End of List
Remove the nth node from the end in one pass.
Why does this pattern fit?
Restate the exact job
Remove the nth node from the end in one pass.
A fixed gap lets the trailing pointer land before the removal node.
O(n) time · O(1) space
Without a dummy node, removing the head needs a special case.
How to solve Remove Nth Node From End of List
The goal is to solve this problem from the pattern, not to memorize a finished answer. Use this as a check after your own attempt.
What the question asks
Remove the nth node from the end in one pass.
Why Linked-list rewiring fits
A fixed gap lets the trailing pointer land before the removal node.
State to maintain
Dummy node plus fast and slow pointers n + 1 edges apart.
Transition
Advance fast, move both until fast ends, then bypass slow.next.
Time and space
O(n) time · O(1) space
Counterexample to the tempting mistake
Without a dummy node, removing the head needs a special case.
Prove it again tomorrow
Close this page. Rebuild the state and transition from memory, write a test that exposes the mistake above, then solve a fresh input without looking back. A same-day reread is practice, not proof of retention.