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.
# . # # . # . # # # # . # . # # . #
seats = [["#",".","#","#",".","#"],[".","#","#","#","#","."],["#",".","#","#",".","#"]]4. # # # # . # # . #
seats = [[".","#"],["#","#"],["#","."],["#","#"],[".","#"]]3Constraints
- seats contains only characters '.' and '#'.
- m == seats.length
- n == seats[i].length
- 1 <= m <= 8
- 1 <= n <= 8
Asked at 3 companies
Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.