Cinema Seat Allocation (Leetcode 1386)

Veröffentlicht am: 26 März 2020
auf dem Kanal: Coding Interviews
5,720
42

Cinema Seat Allocation

https://github.com/pravhub/Coding-Int...

Amazon, Microsoft, Google, Facebook, Netflix, Apple

A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled 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 labelled with 8 is already reserved.

Return the maximum number of four-person families you can allocate on the cinema seats. A four-person family occupies fours seats in one row, that are next to each other. Seats across an aisle (such as [3,3] and [3,4]) are not considered to be next to each other, however, It is permissible for the four-person family to be separated by an aisle, but in that case, exactly two people have to sit on each side of the aisle.



Example 1:



Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
Output: 4
Explanation: The figure above shows the optimal allocation for four families, where seats mark with blue are already reserved and contiguous seats mark with orange are for one family.
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


Auf dieser Seite können Sie das Online-Video Cinema Seat Allocation (Leetcode 1386) mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Coding Interviews 26 März 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 5,720 Mal angesehen und es wurde von 42 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!