IBMOA #9
Remove Even-Value Nodes from Linked List
Estimated EasyJudge-ready
Topics (AI-labelled)Linked Lists
Delete all nodes with even values from a singly linked list, keep the remaining nodes in their original order, and return the full list.
Input
The first line contains n, and the second line contains n node values. On this site 0≤n≤200000, −10^9≤value≤10^9.
Output
Output the number of remaining nodes on the first line and the node values in list order on the second line; for an empty list the second line may be empty.
Example 1
Input:
7
1 2 3 4 5 6 7
Output:
4
1 3 5 7
Example 2
Input:
2
2 4
Output:
0
Example 3
Input:
4
-2 -3 0 5
Output:
2
-3 5
Example notes
The output counts and sequences are: 4 and 1 3 5 7; 0; 2 and −3 5.
Editorial
Loading solution…