Count Matrix Cells Whose Row and Column Neighbors Match
Given a 2D matrix, count the number of cells where all other values in the same row and all other values in the same column are identical. The candidate cell itself should be excluded from this comparison.
Constraints & Assumptions:
- The matrix will have at least one row and one column, unless otherwise clarified.
- When checking a cell's row and column, exclude the candidate cell itself.
- If a row or column has no other cells to compare (e.g., a 1x1 matrix, or a cell in a single-element row/column), the condition should be explicitly defined.
- Values in the matrix can be compared for equality.
AI interview prep
Core dilemma
Efficiently checking the uniformity of row and column elements for each cell without redundant computations, especially as matrix size grows.
2 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Count Matrix Cells Whose Row and Column Neighbors Match
Given a 2D matrix, count the number of cells where all other values in the same row and all other values in the same column are identical. The candidate cell itself should be excluded from this comparison.
Constraints & Assumptions:
- The matrix will have at least one row and one column, unless otherwise clarified.
- When checking a cell's row and column, exclude the candidate cell itself.
- If a row or column has no other cells to compare (e.g., a 1x1 matrix, or a cell in a single-element row/column), the condition should be explicitly defined.
- Values in the matrix can be compared for equality.