当前位置:网站首页>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;
}
}
边栏推荐
- Offline installation of Wireshark 2.6.10
- Measurement of quadrature axis and direct axis inductance of three-phase permanent magnet synchronous motor
- 2022年聚合工艺考试题及模拟考试
- How to do the performance pressure test of "Health Code"
- 2022危险化学品生产单位安全生产管理人员题库及答案
- 2022年T电梯修理题库及模拟考试
- Ten wastes of software research and development: the other side of research and development efficiency
- 数据加载及预处理
- Annual inventory review of Alibaba cloud's observable practices in 2021
- Knowledge supplement: basic usage of redis based on docker
猜你喜欢

Introduction to JVM stack and heap

Annual inventory review of Alibaba cloud's observable practices in 2021

Threejs opening

Pytorch(四) —— 可视化工具 Visdom

Pytorch(二) —— 激活函数、损失函数及其梯度
![[learn C and fly] S1E20: two dimensional array](/img/68/34fad73ff23d3e0719ef364fc60cb5.jpg)
[learn C and fly] S1E20: two dimensional array
![[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached](/img/ec/96e3188902e399f536ebca79042af9.png)
[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached

Section 27 remote access virtual private network workflow and experimental demonstration

JVM栈和堆简介

Knowledge supplement: basic usage of redis based on docker
随机推荐
Use winmtr software to simply analyze, track and detect network routing
Odeint et GPU
MySQL advanced -- you will have a new understanding of MySQL
2022 question bank and answers for safety production management personnel of hazardous chemical production units
How do I sort a list of strings in dart- How can I sort a list of strings in Dart?
Leetcode learning - day 36
How to do the performance pressure test of "Health Code"
Maixll-Dock 使用方法
After many job hopping, the monthly salary is equal to the annual salary of old colleagues
Task04 | statistiques mathématiques
如何看待智慧城市建设中的改变和机遇?
1. Mobile terminal touch screen event
Section 27 remote access virtual private network workflow and experimental demonstration
What is uid? What is auth? What is a verifier?
Caijing 365 stock internal reference | the first IPO of Beijing stock exchange; the subsidiary of the recommended securities firm for gambling and gambling, with a 40% discount
Codeforces Round #771 (Div. 2) ABCD|E
[pat (basic level) practice] - [simple simulation] 1064 friends
Task04 mathematical statistics
先有网络模型的使用及修改
OSPF notes [multiple access, two multicast addresses with OSPF]