Count Negatives in Sorted Matrix Problem
Count Negatives in Sorted Matrix Problem — ExecCode Easy DSA Practice
Solve the Count Negatives in Sorted Matrix problem on ExecCode. Free online easy DSA practice in Matrix. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
Examples
Input {"grid": [[4, 3, 2, -1], [3, 2, 1, -2], [1, 0, -1, -3], [-1, -2, -3, -4]]}; Output 8. Input {"grid": [[3, 2], [1, 0]]}; Output 0. Input {"grid": [[-1]]}; Output 1
Constraints
m == grid.length n == grid[i].length 1 <= m, n <= 100 -100 <= grid[i][j] <= 100
Practice Count Negatives in Sorted Matrix free on ExecCode. Browse DSA problems, topic map, and placement guides.