You are given a binary matrix mat with m rows and n columns.
A cell (i, j) is considered special if:
mat[i][j] is 1, and
every other value in row i is 0, and
every other value in column j is 0
In simple terms, the cell must be the only 1 in both its row and its column.
Return how many such special cells exist in the matrix.
Input: mat = [[0,1,0],[1,0,0],[0,0,1]]
Output: 2
Explanation:
Special cells are at (0,1) and (2,2).
Input: mat = [[1,0],[0,0],[0,1]]
Output: 2
Explanation:
Special positions: (0,0) and (2,1).
Accepted:
Submission: