LeetCode 19 ·
Medium
Remove Nth Node From End of List
Remove the nth node from the end and return the head.
Try it
Step through the core mechanic. The simulator below runs the linked list shape this problem is built on.
Walk the pattern
No dedicated step-through for this one yet. The shape is Linked list — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.
The approach
Advance a lead pointer n steps, then move lead and a trail pointer together until lead falls off. Trail now sits just before the target. A dummy head handles removing the first node.
| Aspect | Value |
|---|---|
| Pattern | Linked list |
| Recognise it by | Nth-from-end in one pass — gap of two pointers. |
| Time complexity | O(n) |
| Space complexity | O(1) |
| Difficulty | Medium |
Who asks it
Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.