1582. Special Positions in a Binary Matrix
https://leetcode.com/problems/special-positions-in-a-binary-matrix
Description
Given a rows x cols
matrix mat
, where mat[i][j]
is either 0
or 1
, 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
(rows and columns are 0-indexed).
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
rows == mat.length
cols == mat[i].length
1 <= rows, cols <= 100
mat[i][j]
is0
or1
.
ac
Last updated