5340. 统计有序矩阵中的负数

104 阅读1分钟

leetcode-cn.com/problems/co…

class Solution {
    fun countNegatives(grid: Array<IntArray>): Int {
        var cnt = 0
        for (item in grid) {
            for (tmp in item) {
                if (tmp < 0) cnt += 1
            }
        }
        return cnt
    }
}