A cinema has n rows of seats, numbered from 1 to n. Each row has 10 seats, numbered from 1 to 10. You are given a 2D integer array reservedSeats, where reservedSeats[i] = [row_i, seat_i] means that seat seat_i in row row_i is already reserved. A four-person group must be assigned to four seats in the same row. The group can be seated in one of the following seat blocks: - seats 2, 3, 4, 5 - seats 4, 5, 6, 7 - seats 6, 7, 8, 9 A block can be used only if none of its seats are reserved. Each seat can be assigned to at most one group. Return an integer denoting the maximum number of four-person groups that can be assigned.
Example 1
Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
Output: 4
Explanation: Row 1 has seats 2, 3 and 8 reserved, so only the middle block 4-7 is free (+1). Row 2 has seat 6 reserved, so only the left block 2-5 is free (+1). Row 3 has only the aisle-end seats 1 and 10 reserved, so both the left and right blocks fit (+2). The total is 4.
Example 2
Input: n = 2, reservedSeats = [[2,1],[1,8],[2,6]]
Output: 2
Explanation: Row 1 has seat 8 reserved, which blocks the right block but leaves the left block 2-5 free (+1). Row 2 has seats 1 and 6 reserved, and the left block 2-5 is still free (+1). The total is 2.
Example 3
Input: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]
Output: 4
Explanation: Rows 2 and 3 have no reservations, so each fits two groups (seats 2-5 and 6-9), giving 4. Row 1 (seats 4 and 7 taken) and row 4 (seats 3 and 6 taken) break every block, so they add nothing.
Only seats 2-9 matter, and each row fits at most two groups. Any row with no reservation in 2-9 always seats two groups, so count those in bulk and only inspect the rows that actually appear in the reservations.
Run checks all cases above. Submit evaluates all test cases.