python-algorithm

leetcode 1351. Count Negative Numbers in a Sorted Matrix

무적김두칠 2022. 3. 20. 16:44

1
2
3
4
5
6
7
class Solution:
    def countNegatives(self, grid: List[List[int]]) -> int:
        cnt=0
        for i in grid:
            for j in i:
                if j<0: cnt+=1
        return cnt
cs
반응형