mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
52
leetcode/problem/maximum-students-taking-exam.html
Normal file
52
leetcode/problem/maximum-students-taking-exam.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<p>Given a <code>m * n</code> matrix <code>seats</code> that represent seats distributions in a classroom. If a seat is broken, it is denoted by <code>'#'</code> character otherwise it is denoted by a <code>'.'</code> character.</p>
|
||||
|
||||
<p>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 <strong>maximum </strong>number of students that can take the exam together without any cheating being possible..</p>
|
||||
|
||||
<p>Students must be placed in seats in good condition.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img height="200" src="https://assets.leetcode.com/uploads/2020/01/29/image.png" width="339" />
|
||||
<pre>
|
||||
<strong>Input:</strong> seats = [["#",".","#","#",".","#"],
|
||||
[".","#","#","#","#","."],
|
||||
["#",".","#","#",".","#"]]
|
||||
<strong>Output:</strong> 4
|
||||
<strong>Explanation:</strong> Teacher can place 4 students in available seats so they don't cheat on the exam.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> seats = [[".","#"],
|
||||
["#","#"],
|
||||
["#","."],
|
||||
["#","#"],
|
||||
[".","#"]]
|
||||
<strong>Output:</strong> 3
|
||||
<strong>Explanation:</strong> Place all students in available seats.
|
||||
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> seats = [["#",".","<strong>.</strong>",".","#"],
|
||||
["<strong>.</strong>","#","<strong>.</strong>","#","<strong>.</strong>"],
|
||||
["<strong>.</strong>",".","#",".","<strong>.</strong>"],
|
||||
["<strong>.</strong>","#","<strong>.</strong>","#","<strong>.</strong>"],
|
||||
["#",".","<strong>.</strong>",".","#"]]
|
||||
<strong>Output:</strong> 10
|
||||
<strong>Explanation:</strong> Place students in available seats in column 1, 3 and 5.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>seats</code> contains only characters <code>'.'<font face="sans-serif, Arial, Verdana, Trebuchet MS"> and</font></code><code>'#'.</code></li>
|
||||
<li><code>m == seats.length</code></li>
|
||||
<li><code>n == seats[i].length</code></li>
|
||||
<li><code>1 <= m <= 8</code></li>
|
||||
<li><code>1 <= n <= 8</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user