| https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/description/ | Easy |
|---|
class Solution {
fun countNegatives(grid: Array<IntArray>): Int {
val m = grid.size
val n = grid[0].size
var count = 0
var row = m - 1
var col = 0
while (row >= 0 && col < n) {
if (grid[row][col] < 0) {
count += n - col
row--
} else {
col++
}
}
return count
}
}