FunctionRacerProblemsRace

Count Negatives in a Sorted Grid

BeginnerGridsPython, JavaScript, TypeScript, Java, C++

Every row and every column of grid is sorted in non-increasing order (biggest first). Return how many numbers in the grid are negative.

Example 1

grid [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]
returns 8

There are 8 negative numbers.

Example 2

grid [[3,2],[1,0]]
returns 0

No negatives.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Grids problems