Linked ListTwo Pointers
Remove the k-th node from the end of a linked list and print the resulting list. Try to do it in one pass. The values are given as an array; build the linked list from them yourself, then solve it with pointers.
Input
Line 1: n. Line 2: the n node values. Line 3: k.
Output
Print the remaining values on one line, or empty if no nodes remain.
Constraints
1 <= k <= n <= 10^4
Example 1
Input
5 1 2 3 4 5 2
Output
1 2 3 5
The second node from the end is 4.
Example 2
Input
1 1 1
Output
empty
Removing the only node leaves an empty list.