We’re preparing your current view and syncing the latest data.
Special Positions in Binary Matrix
gfgGiven an m x n binary matrix mat, return the number of special positions in mat.
A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0.
The input is a 2D integer matrix of size m x n, where each element is either 0 or 1.
Return an integer representing the count of special positions in the given matrix.
1 <= m, n <= 100 mat[i][j] is either 0 or 1
Example 1
Input
[[1,0,0],[0,0,1],[1,0,0]]
Output
1
Explanation
Only position (1,2) is special because it contains 1 and all other entries in the same row and column are 0.