# Ninja And The Class Room

Easy
0/40
Average time to solve is 12m
Contributed by

## Problem statement

Ninja has been asked to make the seating arrangement during the exam. Given an array ‘A’ of ‘N’ integers where ‘A[i] = 1’ means there is a student seated at the index ‘i’ and ‘A[i] = 0’ means that the place is currently unoccupied.

Provided no two students can seat adjacent to each other Ninjas has been asked to place extra ‘K’ students in the classroom.

Return 1 if the Ninja is able to place that extra ‘K’ student else return 0.

Example :
``````Input: ‘N’ = 7, ‘K’ = 2, ‘A’ = [1, 0, 0, 0, 1, 0, 0]
Output: 1

It is possible to place locations 2 and 6 (0-indexed) the updated array will be [1, 0, 1, 0, 1, 0, 1] Here no two students are adjacent to each other.
``````
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
``````1 ≤ T ≤ 10
1 ≤ N ≤ 10^5
0 ≤ K ≤ 10^9
0 ≤ ‘A[i]’ ≤ 1
It is guaranteed that the sum of ‘N’ is ≤ 10^5 for all test cases.

Time limit: 1 sec
``````
##### Sample Input 1 :
``````2
5 2
1 0 0 0 0
2 1
0 1
``````
##### Sample Output 1 :
``````1
0
``````
##### Explanation For Sample Input 1 :
``````For test case 1:
It is possible to place at locations 2 and 4 (0-indexed) the updated array will be [1, 0, 1, 0, 1] Here no two students are adjacent to each other.

For test case 2:
For any possible combinations, there is no way to place the students.
``````
##### Sample Input 2 :
``````2
4 1
1 1 1 1
2 1
0 0
``````
##### Sample Output 2 :
``````0
1
``````
Console