Implement the function that determines whether you can or cannot seat a number of people in the row.

 

Problem

People are sitting in a theater row and you’re an usher.

Given a row of seats that either occupied (1) or unoccupied (0) and the condition that new people being seated do not like to sit next to anyone else.

Implement the function that determines whether you can or cannot seat a number of people in the row.


Input: [1,0,0,0,0,0,1,0,0] 3 => true 4 => false Input: [1,0,0,1,0,0,1,0,0] 1 => true 2 => false Input: [0] 1 => true 2 => false

 

Solution

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons