FreeCareerPath
Build the PrimitiveMedium

Remove Nth Node From End of List

Write `remove_nth_from_end(head, n)` removing the nth node counted from the end, and returning the head. [1,2,3,4,5], n = 2 -> [1,2,3,5] Counting the length first and walking again is two passes. Instead open a gap of n nodes between two pointers and advance both until the leader falls off — the trailing pointer is then exactly where you need it. Start from a dummy head so that removing the first node needs no separate branch.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Remove Nth Node From End of List" are saved to your account — logging in takes a few seconds.

Remove Nth Node From End of List — FreeCareerPath