Delete the Middle Node of a Linked List
Delete the middle node of a singly linked list in one traversal.
Input format
The first line contains N — the number of nodes. The second line contains the N node values in list order.
Output format
Delete the middle node (the ⌊N/2⌋-th node, 0-based) and print the resulting list (print -1 if it becomes empty).
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
5
1 2 3 4 5Expected output
1 2 4 5Example 2
Input
1
9Expected output
-1