Medium · Math

Cinema Seat Allocation

A cinema has n rows of ten seats numbered 1–10, with aisles after seats 3 and 7. Given n and the reserved seats as [row, seat] pairs, return the maximum number of four-person families that can be seated in four free adjacent seats of one row, where an aisle may only split a family two and two (so the usable blocks are 2–5, 4–7 and 6–9).

Examples

Example 1

n=3, reservedSeats=[[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]

Output: 4 families

Example 2

n=2, reservedSeats=[[2,1],[1,8],[2,6]]

Output: 2 families

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Math problems