1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# 1582. Special Positions in a Binary Matrix
"""
given an 'm 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 a row and column are 0
"""
class Solution(object):
def numSpecial(self, mat):
"""
:type mat: List[List[int]]
:rtype: int
"""
if __name__ == "__main__":
obj = Solution()
print(obj.numSpecial(mat=[[1, 0, 0], [0, 0, 1], [1, 0, 0]])) # expect: 1
print(obj.numSpecial(mat=[[1, 0, 0], [0, 1, 0], [0, 0, 1]])) # expect: 3
|