Close
Topic list
Ninja And The Class Room
EASY
12 mins
Greedy
Arrays
Topics (Covered in this problem)
Problem solved
Skill meter
Greedy
-
-
Arrays
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Tries
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Ninja And The Class Room

Contributed by
Omkar Deshmukh
Easy
0/40
Avg time to solve 12 mins
Success Rate 89 %
Share

## Problem Statement

#### 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, Constraints, Images )
##### 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
``````
Auto
Console