当前位置:网站首页>Leetcode 1380. Lucky numbers in the matrix (save the minimum number of each row and the maximum number of each column)
Leetcode 1380. Lucky numbers in the matrix (save the minimum number of each row and the maximum number of each column)
2022-07-01 17:51:00 【wwxy261】

Note that all numbers are different , So there is no need to use index to judge
class Solution {
public:
vector<int> luckyNumbers (vector<vector<int>>& matrix) {
int m = matrix.size(), n = matrix[0].size();
vector<int> minRow(m, INT_MAX), maxCol(n);
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
minRow[i] = min(minRow[i], matrix[i][j]);
maxCol[j] = max(maxCol[j], matrix[i][j]);
}
}
vector<int> ans;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (matrix[i][j] == minRow[i] && matrix[i][j] == maxCol[j]) {
ans.emplace_back(matrix[i][j]);
}
}
}
return ans;
}
};边栏推荐
- 深度优先遍历和广度优先遍历[通俗易懂]
- February 16, 2022 Daily: graph neural network self training method under distribution and migration
- (12) About time-consuming printing
- Sword finger offer 20 String representing numeric value
- PETRv2:一个多摄像头图像3D感知的统一框架
- Redis主从实现10秒检查与恢复
- Is it safe to open an ETF account online? What are the steps?
- Mysql database - Advanced SQL statement (2)
- Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
- Development cost of smart factory management system software platform
猜你喜欢

New 95 community system whole station source code

Good looking UI mall source code has been scanned, no back door, no encryption

多线程使用不当导致的 OOM

vulnhub靶场-hacksudo - Thor
![[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①](/img/24/23f6534e2c74724f9512c5b18661b6.png)
[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①

Work and leisure suggestions of old programmers

(1) CNN network structure

Kernel stray cat stray dog pet adoption platform H5 source code

Common design parameters of solid rocket motor

Yyds dry inventory MySQL RC transaction isolation level implementation
随机推荐
传感器尺寸、像素、DPI分辨率、英寸、毫米的关系
DNS
Object. fromEntries()
中国超高分子量聚乙烯产业调研与投资前景报告(2022版)
SQL injection vulnerability (MySQL and MSSQL features)
Penetration practice vulnhub range Nemesis
New 95 community system whole station source code
徽商期货是正规期货平台吗?在徽商期货开户安全吗?
June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries
Mysql database - Advanced SQL statement (2)
In depth Research Report on China's disposable sanitary products production equipment industry (2022 Edition)
Petrv2: a unified framework for 3D perception of multi camera images
China PBAT resin Market Forecast and Strategic Research Report (2022 Edition)
ArrayList扩容详解
Three dimensional anti-terrorism Simulation Drill deduction training system software
New patent applications and transfers
vulnhub靶场-Hacker_Kid-v1.0.1
The latest intelligent factory MES management system software solution
D @ safety and dip1000
JDBC:深入理解PreparedStatement和Statement[通俗易懂]