当前位置:网站首页>Leecode record 1351 negative numbers in statistical ordered matrix
Leecode record 1351 negative numbers in statistical ordered matrix
2022-07-01 04:41:00 【Why is there a bug list】
topic
To give you one m * n Matrix grid, The elements of a matrix, whether by row or column , All in non increasing order .
Please count and return grid in negative Number of .
Example 1:
Input :grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]
Output :8
explain : Common matrix 8 Negative numbers .
Example 2:
Input :grid = [[3,2],[1,0]]
Output :0
Example 3:
Input :grid = [[1,-1],[-1,-1]]
Output :3
Example 4:
Input :grid = [[-1]]
Output :1
Tips :
m == grid.length
n == grid[i].length
1 <= m, n <= 100
-100 <= grid[i][j] <= 100
answer
class Solution {
public int countNegatives(int[][] grid) {
int count = 0;
for(int i = 0; i < grid.length; i++)
{
for (int j = 0; j < grid[i].length ; j++)
{
if(grid[i][j] < 0)
{
count += grid[i].length - j;
break;
}
}
}
return count;
}
}
边栏推荐
- 使用WinMTR软件简单分析跟踪检测网络路由情况
- CUDA development and debugging tool
- 什么是权限?什么是角色?什么是用户?
- 2022 t elevator repair question bank and simulation test
- 如何看待智慧城市建设中的改变和机遇?
- Announcement on the list of Guangdong famous high-tech products to be selected in 2021
- [leetcode skimming] February summary (updating)
- Why is Hong Kong server most suitable for overseas website construction
- Cmake selecting compilers and setting compiler options
- After many job hopping, the monthly salary is equal to the annual salary of old colleagues
猜你喜欢

VIM简易使用教程

Software testing needs more and more talents. Why do you still not want to take this path?
![[leetcode skimming] February summary (updating)](/img/62/0d0d9f11434e49d33754a2e4f2ea65.jpg)
[leetcode skimming] February summary (updating)

OdeInt與GPU

Kodori tree board

(12) Somersault cloud case (navigation bar highlights follow)

Pytest automated testing - compare robotframework framework

2022 t elevator repair question bank and simulation test
![[human version] Web3 privacy game in the dark forest](/img/89/e16789b7f3892002748aab309c45e6.png)
[human version] Web3 privacy game in the dark forest

Mallbook: how can hotel enterprises break the situation in the post epidemic era?
随机推荐
2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities
JVM栈和堆简介
Software testing needs more and more talents. Why do you still not want to take this path?
2022 polymerization process test questions and simulation test
2022 gas examination question bank and online simulation examination
Leetcode learning - day 36
Offline installation of Wireshark 2.6.10
How to ensure the idempotency of the high concurrency interface?
About the transmission pipeline of stage in spark
数据加载及预处理
尺取法:有效三角形的个数
Daily algorithm & interview questions, 28 days of special training in large factories - the 13th day (array)
The design points of voice dialogue system and the importance of multi round dialogue
Annual inventory review of Alibaba cloud's observable practices in 2021
PgSQL failed to start after installation
Simple implementation of slf4j
How to use maixll dock
Pytorch(一) —— 基本语法
2022 hoisting machinery command registration examination and hoisting machinery command examination registration
OdeInt与GPU