Maximum Students Taking Exam
Given an m * n matrix seats that represents the seat distribution in a classroom. If a seat is broken, it is denoted by the '#' character; otherwise, it is denoted by the '.' character.
Students can see the answers of those sitting next to the left, right, upper left, and upper right, but they cannot see the answers of the student sitting directly in front of or behind them.
Return the maximum number of students that can take the exam together without any cheating being possible.
Students must be placed only in seats in good condition.
Example 1
# . # # . # . # # # # . # . # # . #
Input
seats = [["#",".","#","#",".","#"],[".","#","#","#","#","."],["#",".","#","#",".","#"]]Output
4Teacher can place 4 students in available seats so they do not cheat on the exam.
Example 2
. # # # # . # # . #
Input
seats = [[".","#"],["#","#"],["#","."],["#","#"],[".","#"]]Output
3All students can be placed in available seats.
Constraints
- seats contains only characters '.' and '#'.
- m == seats.length
- n == seats[i].length
- 1 <= m <= 8
- 1 <= n <= 8