Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit871a678

Browse files
refactor 1386
1 parentc2c548c commit871a678

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

‎src/main/java/com/fishercoder/solutions/_1386.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,6 @@
55
importjava.util.Map;
66
importjava.util.Set;
77

8-
/**
9-
* 1386. Cinema Seat Allocation
10-
*
11-
* 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.
12-
* 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.
13-
* 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.
14-
* 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.
15-
*
16-
* Example 1:
17-
* Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
18-
* Output: 4
19-
* 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.
20-
*
21-
* Example 2:
22-
* Input: n = 2, reservedSeats = [[2,1],[1,8],[2,6]]
23-
* Output: 2
24-
*
25-
* Example 3:
26-
* Input: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]
27-
* Output: 4
28-
*
29-
* Constraints:
30-
* 1 <= n <= 10^9
31-
* 1 <= reservedSeats.length <= min(10*n, 10^4)
32-
* reservedSeats[i].length == 2
33-
* 1 <= reservedSeats[i][0] <= n
34-
* 1 <= reservedSeats[i][1] <= 10
35-
* All reservedSeats[i] are distinct.
36-
* */
378
publicclass_1386 {
389
publicstaticclassSolution1 {
3910
publicintmaxNumberOfFamilies(intn,int[][]reservedSeats) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp