Skip to content

Practice Cinema Seat Allocation

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1386
LeetCode Problem

Cinema Seat Allocation

Problem Statement

The cinema has n rows, numbered 1 through n, with seats 1 through 10 in each row. reservedSeats contains [row, seat] pairs that are unavailable. A four-person group may occupy seats 2–5, 4–7, or 6–9 within one row. Every seat in its block must be unreserved, and no seat may be assigned to more than one group. Return the maximum number of groups that can be seated.

Source: Cinema Seat Allocation on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

# Example 3

Input
n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]
Output
4

Constraints

1 <= n <= 10^9
1 <= reservedSeats.length <= min(10*n, 10^4)
reservedSeats[i].length == 2
1 <= reservedSeats[i][0] <= n
1 <= reservedSeats[i][1] <= 10
All reservedSeats[i] are distinct.

Related LeetCode Problems

Practice more problems similar to Cinema Seat Allocation.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.