# Count Even Or Odd

Posted: 27 Apr, 2021

Difficulty: Hard

#### Tanmay and Rohit are best buddies. One day Tanmay gives Rohit a problem to test his intelligence and skills. He gives him an array of N natural numbers and asks him to solve the following queries:-

**Query 0** :

```
0 x y
```

#### This operation modifies the element present at index x to y.

**Query 1** :

```
1 x y
```

#### This operation counts the number of even numbers in range x to y inclusive.

**Query 2** :

```
2 x y
```

#### This operation counts the number of odd numbers in range x to y inclusive.

##### Input Format :

```
The first line of the test case contains a single integer ‘N’ denoting the size of the ‘arr’ array.
The second line of each test case contains ‘N’ space-separated integers denoting the elements array ‘arr’.
The third line of each test case contains an integer ‘q’ denoting the number of queries.
The next ‘q’ lines of each test case contain 3 space-separated integers denoting the following:
0 x y - modify the number at index x to y.
1 x y - count the number of even numbers in range x to y inclusive.
2 x y - count the number of odd numbers in range x to y inclusive.
```

##### Output Format :

```
For each query, print an integer denoting the answer.
The output of each query will be printed in a separate line.
```

##### Constraints :

```
1 <= N, Q <= 10^5
0 <= l <= r <= N - 1
0 <= arr[i] <= 10 ^ 9
1 <= x <= N
0 <= y <= 10 ^ 9
Where 'arr[i]' denotes the 'ith' element of arr.
Time limit: 1 sec
```

##### Note :

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

SIMILAR PROBLEMS

Ninja Land

Posted: 1 Jul, 2021

Difficulty: Ninja

Ninja Land

Posted: 1 Jul, 2021

Difficulty: Ninja

Sum of Shadows

Posted: 16 Sep, 2021

Difficulty: Moderate

Chocolate and Sweetness

Posted: 9 Oct, 2021

Difficulty: Hard

Chocolate and Sweetness

Posted: 9 Oct, 2021

Difficulty: Hard

Range Minimum Query

Posted: 2 Nov, 2021

Difficulty: Hard

Ninja and Tree

Posted: 5 Feb, 2022

Difficulty: Ninja