lc-go/solutions/13/q1351/solution.go
2025-12-29 08:46:00 +09:00

17 lines
258 B
Go

package q1351
func countNegatives(grid [][]int) int {
w := len(grid[0])
count := 0
countRow := 0
for r := range grid {
for countRow < w && (grid[r][w-countRow-1] < 0) {
countRow++
}
count += countRow
}
return count
}
var _ = countNegatives