1349. Maximum Students Taking Exam Hard

@problem@discussion
#Array#Dynamic Programming#Bit Manipulation#Matrix#Bitmask



1/**
2 * [1349] Maximum Students Taking Exam
3 *
4 * Given a m * n matrix seats  that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.
5 * 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..
6 * Students must be placed in seats in good condition.
7 *  
8 * Example 1:
9 * <img height="200" src="https://assets.leetcode.com/uploads/2020/01/29/image.png" width="339" />
10 * Input: seats = [["#",".","#","#",".","#"],
11 *                 [".","#","#","#","#","."],
12 *                 ["#",".","#","#",".","#"]]
13 * Output: 4
14 * Explanation: Teacher can place 4 students in available seats so they don't cheat on the exam. 
15 * 
16 * Example 2:
17 * 
18 * Input: seats = [[".","#"],
19 *                 ["#","#"],
20 *                 ["#","."],
21 *                 ["#","#"],
22 *                 [".","#"]]
23 * Output: 3
24 * Explanation: Place all students in available seats. 
25 * 
26 * Example 3:
27 * 
28 * Input: seats = [["#",".",".",".","#"],
29 *                 [".","#",".","#","."],
30 *                 [".",".","#",".","."],
31 *                 [".","#",".","#","."],
32 *                 ["#",".",".",".","#"]]
33 * Output: 10
34 * Explanation: Place students in available seats in column 1, 3 and 5.
35 * 
36 *  
37 * Constraints:
38 * 
39 * 	seats contains only characters '.'<font face="sans-serif, Arial, Verdana, Trebuchet MS"> and</font>'#'.
40 * 	m == seats.length
41 * 	n == seats[i].length
42 * 	1 <= m <= 8
43 * 	1 <= n <= 8
44 * 
45 */
46pub struct Solution {}
47
48// problem: https://leetcode.com/problems/maximum-students-taking-exam/
49// discuss: https://leetcode.com/problems/maximum-students-taking-exam/discuss/?currentPage=1&orderBy=most_votes&query=
50
51// submission codes start here
52
53impl Solution {
54    pub fn max_students(seats: Vec<Vec<char>>) -> i32 {
55        0
56    }
57}
58
59// submission codes end
60
61#[cfg(test)]
62mod tests {
63    use super::*;
64
65    #[test]
66    fn test_1349() {
67    }
68}
69


Back
© 2025 bowen.ge All Rights Reserved.