LinkedList Simulate Number of Even Elements
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
An empty Linked List is given initially. Simulate the next operations:
push front x: add element x to the front of a Linked List;
push back x: add element x to the back of a Linked List;
pop front: remove element from the front of a Linked List;
pop back: remove element from the back of a Linked List;
Let L = (a[1]
, a[2]
, ...., a[n]
) be the resulting Linked List. Find the number of all its even elements.
Input
Each line contains one of the operations described above. It is known that x is a nonnegative integer, no more than 1000. Final Linked List (after simulation) contains no more than 1000 elements.
Output
Print the number of all even elements in the resulting Linked List.
Example
After simulation the list will have the next form:
The number of even elements is 1.
Examples
Input #1
Answer #1
Submissions 43
Acceptance rate 65%