Given the head of a linked list, remove the nth node from the end of the list and return its head.
Example 1
Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
Explanation: Counting from the end, 5 is 1st and 4 is 2nd. Removing 4 links 3 directly to 5, giving [1,2,3,5].
Example 2
Input: head = [1], n = 1
Output: []
Explanation: The only node is the 1st from the end, so removing it leaves an empty list.
Example 3
Input: head = [1,2], n = 1
Output: [1]
Explanation: The 1st node from the end is 2. Removing it leaves [1].
Advance a fast pointer n nodes ahead of a slow pointer, then move both together. When fast reaches the end, slow sits exactly on the node before the one to remove — so unlink it in a single pass.
Run checks all cases above. Submit evaluates all test cases.