38. Remove Nth Node From End of List

Remove the n-th node from the end of the list and return the head. Try to do it in one pass.

Example 1

Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]

Example 2

Input: head = [1], n = 1
Output: []
Hint 1

Move a fast pointer n+1 steps ahead, then move both until fast falls off the end.

Hint 2

A dummy node handles deleting the head.

Linked ListTwo Pointers