1582. Special Positions in a Binary Matrix
Содержание
class Solution:
def numSpecial(self, mat: List[List[int]]) -> int:
m, n = len(mat), len(mat[0])
r = [0] * m
c = [0] * n
for i, row in enumerate(mat):
for j, v in enumerate(row):
r[i] += v
c[j] += v
res = 0
for i in range(m):
for j in range(n):
if mat[i][j] == 1 and r[i] == 1 and c[j] == 1:
res += 1
return res