Practice · 2 of 5
Even Count in Range
CHALLENGE
Difficulty: beginner+25 XP
**Description:** Given n integers and q queries l r, count how many elements
in a[l..r] are even.
**Input:** Line 1: n q (1 <= n, q <= 2*10^5). Line 2: n integers (-10^9 <= a_i <= 10^9).
Next q lines: l r (1 <= l <= r <= n).
**Output:** q lines — the counts.
**Example:** 6 2 / 2 3 4 5 6 7 / 1 6 / 2 4 -> 3 / 1.
Press Submit to check your solution.
Back to lesson: Practice: Prefix Sum Problem Set