Loading...
Loading...
Loading...
A list of tickets is processed in order, and the n-th ticket counted from the end must be cancelled. Remove that node and print the list, or EMPTY if no nodes remain. Do it in one pass.
Example
Input
1 2 3 4 5 2
Output
1 2 3 5
Try the problem first. Open one hint at a time.
Start two pointers at a dummy node and move the first one n steps ahead.
Then move both until the first is on the last node.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor