Tap here to switch tabs
Problem
Submissions

Problem: Maximum Students Taking Exam

Try to solve the Maximum Students Taking Exam problem.

Statement

You are given an mimesnm imes n matrix seats representing a classroom seating arrangement, where:

  • seats[i][j] == '.' represents an available seat.

  • seats[i][j] == '#' represents a broken seat.

A student seated at position (i, j) can see the exam paper of any student seated in the following adjacent positions:

  • Directly to the left: (i, j−1j - 1 )

  • Directly to the right: (i, j+1j + 1 )

  • Diagonally to the front left: (i - 11 , j−1j - 1 )

  • Diagonally to the front right: (i - 11 , j+1j + 1 )

Students cannot see the papers of those sitting directly in front of them or behind them.

Return the maximum number of students who can take the exam simultaneously without any student being able to view another student’s work.

Constraints:

  • seats contains only the characters '.' and '#'.

  • m==m == seats.length

  • n==n == seats[i].length

  • 1≤m≤81 \leq m \leq 8

  • 1≤n≤81 \leq n \leq 8

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Students Taking Exam

Try to solve the Maximum Students Taking Exam problem.

Statement

You are given an mimesnm imes n matrix seats representing a classroom seating arrangement, where:

  • seats[i][j] == '.' represents an available seat.

  • seats[i][j] == '#' represents a broken seat.

A student seated at position (i, j) can see the exam paper of any student seated in the following adjacent positions:

  • Directly to the left: (i, j−1j - 1 )

  • Directly to the right: (i, j+1j + 1 )

  • Diagonally to the front left: (i - 11 , j−1j - 1 )

  • Diagonally to the front right: (i - 11 , j+1j + 1 )

Students cannot see the papers of those sitting directly in front of them or behind them.

Return the maximum number of students who can take the exam simultaneously without any student being able to view another student’s work.

Constraints:

  • seats contains only the characters '.' and '#'.

  • m==m == seats.length

  • n==n == seats[i].length

  • 1≤m≤81 \leq m \leq 8

  • 1≤n≤81 \leq n \leq 8