Given the head of a linked list and an integer n, remove the n-th node from the list (1-indexed) and return the head of the modified list.
Input
head: the head node of a singly linked list
n: an integer representing the position of the node to remove (1-indexed)
Output
Return the head of the modified linked list
Constraints
The list has at least 1 node
n is a valid position in the list (1 <= n <= length of list)
Examples
Example 1
Inputhead = [1, 2, 3], n = 1
Output[2, 3]
ExplanationRemove the 1st node (value 1), return [2, 3]
Example 2
Inputhead = [1, 2, 3], n = 2
Output[1, 3]
ExplanationRemove the 2nd node (value 2), return [1, 3]
Example 3
Inputhead = [1, 2, 3], n = 3
Output[1, 2]
ExplanationRemove the 3rd node (value 3), return [1, 2]