#K88727. Delete Middle Node of a Linked List
Delete Middle Node of a Linked List
Delete Middle Node of a Linked List
You are given a singly linked list. Your task is to delete the middle node of the linked list. If the list has an even number of nodes, delete the second of the two middle nodes. In other words, if the list has n nodes, remove the node at position \(\lfloor \frac{n}{2} \rfloor + 1\) (1-indexed).
If the list is empty or contains only one node, the result should be an empty list.
Examples:
- For the list [1, 2, 3, 4, 5], the middle node is 3, so the output should be [1, 2, 4, 5].
- For the list [2, 4, 6, 7, 5, 1], the two middle nodes are 6 and 7, and the second one (7) is removed. The output should be [2, 4, 6, 5, 1].
Use standard input (stdin) for reading input and standard output (stdout) for printing the result.
inputFormat
The first line contains an integer n (\(n \ge 0\)) representing the number of nodes in the linked list.
If \(n > 0\), the second line contains \(n\) space-separated integers representing the values of the nodes in the order they appear in the list.
If \(n = 0\), there will be no second line.
outputFormat
Output a single line containing the values of the linked list after deleting the middle node. The values should be space-separated. If the resulting linked list is empty, output an empty line.
## sample5
1 2 3 4 5
1 2 4 5
</p>