← All problems

Remove Nth Node From End

Medium linked liststwo-pointers LeetCode ↗
Remove the nth node from the end of a singly linked list in a single pass. For example, removing the 2nd node from the end of 1->2->3->4->5 yields 1->2->3->5. Handle the head-removal edge case.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(1)

Common pitfalls

  • Off-by-one in the gap
  • Crash when removing the head without dummy

Your solution

Log in to save your code and track progress.