rows rows numbered from 1, and each row has 10 seats numbered 1 to 10. Aisles run between seats 3 and 4 and between seats 7 and 8.
The list taken holds the seats already sold: a pair [r, s] means seat s in row r is occupied.
A group of four wants to sit together on four adjacent seats in one row. Seats on opposite sides of an aisle are not adjacent, with one exception: a group may sit so that an aisle splits it exactly in half, two people on each side.
Return the largest number of groups that can be seated.rows=2, taken=[[1, 5], [2, 3], [2, 9]] → 2
In row 1 seat 5 is taken, which blocks the left half and the middle, but seats 6–9 are free: one group. In row 2 seats 3 and 9 are taken, leaving only seats 4–7 between the aisles: one more. Total 2.
rows=3, taken=[[2, 1], [2, 10]] → 6
The edge seats 1 and 10 never get in the way, so each of the three rows fits two groups: 6 in total.
rows=1, taken=[[1, 4], [1, 7]] → 0
Seats 4 and 7 cut through all three possible blocks, so no group fits.
rows ≤ 10⁹rows, 10⁴)taken[i] = [r, s], 1 ≤ r ≤ rows, 1 ≤ s ≤ 10taken are distinctrows=2, taken=[[1, 5], [2, 3], [2, 9]]
2
Run checks the first 3 tests in your browser. Submit checks all 77 tests on the server, hidden ones included.