Trains the technique from
LeetCode 1351Count Negative Numbers in a Sorted MatrixThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A weather board shows temperatures in whole degrees, laid out in rows and columns. chart[i][j] is the temperature in row i, column j.
The board is ordered in both directions: reading a row from left to right, the temperature never goes up, and reading a column from top to bottom, the temperature never goes up either. Every row holds the same number of cells.
Return how many cells of the board show a temperature below zero.
Example 1
The freezing cells are -3 in the first row, -5 in the second, -1 and -8 in the third, and -2, -6 and -9 in the fourth.
Example 2
The cells at zero are not below zero, so only -1, -2 and -3 are counted.
Example 3
No cell on this board is below zero.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_freezing(chart: list[list[int]]) -> int:public int countFreezing(int[][] chart)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.