貌似没啥考点,很友好的题目。
class Solution:
def countNegatives(self, grid: List[List[int]]) -> int:
r = len(grid)
c = len(grid[0])
res = 0
for i in range(r):
for j in range(c):
if grid[i][j] < 0:
res += (c - j)
break
return res