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, 6 reserved

Output: 4 families

Example 2

n=2, 3 reserved

Output: 2 families

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Math problems