当前位置:网站首页>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;
}
};边栏推荐
- 麦趣尔:媒体报道所涉两批次产品已下架封存,受理消费者诉求
- PIP version problems: PIP problems still occur when installing akshare and using Tsinghua source and Douban source
- 徽商期货是正规期货平台吗?在徽商期货开户安全吗?
- 开发那些事儿:EasyCVR集群设备管理页面功能展示优化
- (28) Shape matching based on contour features
- Radhat builds intranet Yum source server
- Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
- The difference and relationship between iteratible objects, iterators and generators
- Thinkphp6 - CMS multi wechat management system source code
- New patent applications and transfers
猜你喜欢

(28) Shape matching based on contour features

Length of learning and changing

SQL injection vulnerability (MySQL and MSSQL features)

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

Penetration practice vulnhub range Nemesis

How to write good code - Defensive Programming Guide

Heavy disclosure! Hundreds of important information systems have been invaded, and the host has become a key attack target
![Htt [ripro network disk link detection plug-in] currently supports four common network disks](/img/e4/c06b94243cdbe391b8b2124ff30789.jpg)
Htt [ripro network disk link detection plug-in] currently supports four common network disks

DNS

An example of data analysis of an old swatch and an old hard disk disassembly and assembly combined with the sensor of an electromagnetic press
随机推荐
《中国智慧环保产业发展监测与投资前景研究报告(2022版)》
(17) DAC conversion experiment
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
Is Huishang futures a regular futures platform? Is it safe to open an account in Huishang futures?
Euler function: find the number of numbers less than or equal to N and coprime with n
Software construction scheme of smart factory collaborative management and control application system
开发那些事儿:EasyCVR平台添加播放地址鉴权
Sword finger offer II 105 Maximum area of the island
MFC obtains local IP (used more in network communication)
Gold, silver and four job hopping, interview questions are prepared, and Ali becomes the champion
Is it reasonable and safe to open a securities account for 10000 shares free of charge? How to say
How to write good code - Defensive Programming Guide
整形数组合并【JS】
MES production equipment manufacturing execution system software
ACL 2022 | decomposed meta learning small sample named entity recognition
Is it safe to open a stock account by mobile phone? What do you need to bring with you to open an account?
手机开户股票开户安全吗?那么开户需要带些什么?
PETRv2:一个多摄像头图像3D感知的统一框架
What are the six steps of the software development process? How to draw software development flow chart?
(十七)DAC转换实验