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

Commit7b10217

Browse files
refactor 1349
1 parente5634ac commit7b10217

File tree

1 file changed

+3
-41
lines changed

1 file changed

+3
-41
lines changed

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

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,11 @@
22

33
importjava.util.Arrays;
44

5-
/**
6-
* 1349. Maximum Students Taking Exam
7-
*
8-
* Given a m * n matrix seats that represent seats distributions in a classroom.
9-
* If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.
10-
* Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible..
11-
* Students must be placed in seats in good condition.
12-
*
13-
* Example 1:
14-
* Input: seats = [["#",".","#","#",".","#"],
15-
* [".","#","#","#","#","."],
16-
* ["#",".","#","#",".","#"]]
17-
* Output: 4
18-
* Explanation: Teacher can place 4 students in available seats so they don't cheat on the exam.
19-
*
20-
* Example 2:
21-
* Input: seats = [[".","#"],
22-
* ["#","#"],
23-
* ["#","."],
24-
* ["#","#"],
25-
* [".","#"]]
26-
* Output: 3
27-
* Explanation: Place all students in available seats.
28-
*
29-
* Example 3:
30-
* Input: seats = [["#",".",".",".","#"],
31-
* [".","#",".","#","."],
32-
* [".",".","#",".","."],
33-
* [".","#",".","#","."],
34-
* ["#",".",".",".","#"]]
35-
* Output: 10
36-
* Explanation: Place students in available seats in column 1, 3 and 5.
37-
*
38-
* Constraints:
39-
* seats contains only characters '.' and'#'.
40-
* m == seats.length
41-
* n == seats[i].length
42-
* 1 <= m <= 8
43-
* 1 <= n <= 8
44-
* */
455
publicclass_1349 {
466
publicstaticclassSolution1 {
47-
/**credit: https://leetcode.com/problems/maximum-students-taking-exam/discuss/503686/A-simple-tutorial-on-this-bitmasking-problem*/
7+
/**
8+
* credit: https://leetcode.com/problems/maximum-students-taking-exam/discuss/503686/A-simple-tutorial-on-this-bitmasking-problem
9+
*/
4810
publicintmaxStudents(char[][]seats) {
4911
intm =seats.length;
5012
intn =seats[0].length;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp