Coding · should-tier · asked at Amazon, Apple, Google, Meta, Microsoft, Netflix
Remove Nth Node From End of List
Problem
You are given the head of a singly linked list and an integer n. Remove the node that is n-th from the end of the list (so n = 1 removes the last node) and return the head of the resulting list. Try to do it in a single traversal.
- The list has between 1 and 100 nodes.
- Node values fit in a signed 32-bit integer.
nis between 1 and the number of nodes, inclusive.
Examples
6 -> 3 -> 9 -> 12 -> 15,n = 2→6 -> 3 -> 9 -> 15. The 12 is second from the end.4,n = 1→ empty list. Removing the only node leaves nothing.8 -> 2,n = 2→2. Removing the head must return the new head.
Hints
- Counting the length first and then walking to position
len - nworks in two passes. What would you need to know during a single pass to stop at the right place? - If a second pointer is always exactly
nnodes ahead of you, where are you when it falls off the end? - Use two pointers with a gap of
n + 1starting from a dummy node before the head, so the trailing pointer lands on the predecessor of the node to remove.
Last reviewed 8 September 2026
Locked
Approach · Solution (Python) · Complexity · Follow-ups · Company variations · Tests
The rest of this question — the worked approach, the Python solution with passing tests, complexity, follow-ups and how each company frames it — is part of the guides.
Get the full guide
Pick the company you're interviewing with. Each guide has every question tiered for that loop — one-time purchase, lifetime access.
Secure payment by Stripe · instant access · refund questions: [email protected]
Also in: Apple, Google, Meta, Microsoft, Netflix
Interviewing at more than one? All 6 guides for $499 · save $395
Not ready to buy? Get the free starter pack — 13 questions with full solutions.