# bookmyshow/paytm seat allocation for groups

A cinema has `n` rows of seats, numbered from 1 to `n` and there are ten seats in each row, labeled from 1 to 10 as shown in the figure above.

Given the array `reservedSeats` containing the numbers of seats already reserved, for example, `reservedSeats[i] = [3,8]` means the seat located in row 3 and labeled with 8 is already reserved.

Example 1:

`Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]Output: 4Explanation: The figure above shows the optimal allocation for four groups, where seats mark with blue are already reserved and contiguous seats mark with orange are for one group.`

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.

# Complexity Analysis

• Time complexity: O(n). The complete array of size n is traversed.
• Space complexity: (). An additional dictionary is used to map the row to seat information.

Full Stack Programmer, love to solve problem’s during free time.

## More from Jaydeep

Full Stack Programmer, love to solve problem’s during free time.