Count Positive Even Numbers
easySave
ArrayCounting
Given an array of integers, return the count of positive even numbers from the array.
Example 1
Input
[ 2, -3, 4, 5, -6 ]
Output
2
Explanation. There are 2 positive even numbers: 2 and 4.
Example 2
Input
[ -1, -2, -3, -4 ]
Output
0
Explanation. There are no positive even numbers in the array.
Example 3
Input
[ 0, 2, 6, 9, 11, 12 ]
Output
3
Explanation. There are 3 positive even numbers: 2, 6, and 12.
Example 4
Input
[]
Output
0
Explanation. The array is empty, so there are no positive even numbers.
Follow-up: How would you handle very large arrays efficiently?
Constraints:
The input array can contain zero and negative integers, but will always be non-null. Array length will not exceed 1000 elements.
- Views
- 4