Imagine you're a proctor overseeing an exam in a classroom with m ร n seats arranged in a grid. Some seats are broken (marked with '#') while functional seats are marked with '.'.
Here's the challenge: students can cheat by looking at answers from their neighbors! Specifically, a student can see the answers of those sitting:
- Directly to their left
- Directly to their right
- To their upper left diagonal
- To their upper right diagonal
However, students cannot see answers from those sitting directly in front or behind them.
Your goal is to find the maximum number of students that can take the exam simultaneously without any possibility of cheating. Students can only be placed in functional seats (marked with '.').
Example: In a classroom where students are seated like chess pieces, you need to ensure no student can peek at their neighbor's paper!
Input & Output
Visualization
Time & Space Complexity
m rows, up to 4^n transitions between valid masks, 2^n possible masks per row
DP table stores maximum students for each row and valid mask combination
Constraints
- m == seats.length
- n == seats[i].length
- 1 โค m โค 8
- 1 โค n โค 8
- seats[i][j] is either '.' or '#'