← 返回 oracle 的题目列表Remove Even-Positioned Nodes from a Singly Linked List
类型:online_judge
Given the head of a singly linked list, remove every node at an even position and return the resulting head. Positions are 1-indexed, so nodes at positions 2, 4, 6, ... must be removed.
Preserve the relative order of the original odd-positioned nodes.
Input
n
v1 v2 ... vn
Output
values of the resulting linked list, separated by spaces
Print an empty line if the result is empty.
Constraints
0 <= n <= 2 * 10^5
Node values fit in a signed 32-bit integer.
Example
Input:
5
1 2 3 4 5
Output:
1 3 5
Example
Input
5
1 2 3 4 5
Output
1 3 5