|
1 | 1 | packagecom.fishercoder.solutions; |
2 | 2 |
|
3 | | -/** |
4 | | - * 1351. Count Negative Numbers in a Sorted Matrix |
5 | | - * |
6 | | - * Given a m * n matrix grid which is sorted in non-increasing order both row-wise and column-wise. |
7 | | - * Return the number of negative numbers in grid. |
8 | | - * |
9 | | - * Example 1: |
10 | | - * Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]] |
11 | | - * Output: 8 |
12 | | - * Explanation: There are 8 negatives number in the matrix. |
13 | | - * |
14 | | - * Example 2: |
15 | | - * Input: grid = [[3,2],[1,0]] |
16 | | - * Output: 0 |
17 | | - * |
18 | | - * Example 3: |
19 | | - * Input: grid = [[1,-1],[-1,-1]] |
20 | | - * Output: 3 |
21 | | - * |
22 | | - * Example 4: |
23 | | - * Input: grid = [[-1]] |
24 | | - * Output: 1 |
25 | | - * |
26 | | - * Constraints: |
27 | | - * m == grid.length |
28 | | - * n == grid[i].length |
29 | | - * 1 <= m, n <= 100 |
30 | | - * -100 <= grid[i][j] <= 100 |
31 | | - * */ |
32 | 3 | publicclass_1351 { |
33 | 4 | publicstaticclassSolution1 { |
34 | 5 | publicintcountNegatives(int[][]grid) { |
|