当前位置:网站首页>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;
}
};
边栏推荐
- (16) ADC conversion experiment
- 聊聊项目经理最爱使用的工具
- 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
- Sword finger offer 20 String representing numeric value
- (27) Open operation, close operation, morphological gradient, top hat, black hat
- Detailed explanation of ArrayList expansion
- Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
- LeetCode中等题之TinyURL 的加密与解密
- At present, where is the most formal and safe account opening for futures speculation? How to open a futures account?
- Wechat applet blind box - docking wechat payment
猜你喜欢
Vulnhub range hacker_ Kid-v1.0.1
多线程使用不当导致的 OOM
Heavy disclosure! Hundreds of important information systems have been invaded, and the host has become a key attack target
【牛客网刷题系列 之 Verilog快速入门】~ 优先编码器电路①
Rotation order and universal lock of unity panel
String的trim()和substring()详解
Enter wechat applet
PETRv2:一个多摄像头图像3D感知的统一框架
transform. Forward and vector3 Differences in the use of forward
Kia recalls some K3 new energy with potential safety hazards
随机推荐
JDBC:深入理解PreparedStatement和Statement[通俗易懂]
《中国智慧环保产业发展监测与投资前景研究报告(2022版)》
Setting up a time server requires the client to automatically synchronize the time of the server at 9 a.m. every day
Thinkphp6 - CMS multi wechat management system source code
(1) CNN network structure
Is Huishang futures a regular futures platform? Is it safe to open an account in Huishang futures?
Data warehouse (3) star model and dimension modeling of data warehouse modeling
Report on research and investment prospects of UHMWPE industry in China (2022 Edition)
Euler function: find the number of numbers less than or equal to N and coprime with n
PHP实现敏感词过滤系统「建议收藏」
From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
Unity3d extended toolbar
(十七)DAC转换实验
RadHat搭建内网YUM源服务器
Htt [ripro network disk link detection plug-in] currently supports four common network disks
China PBAT resin Market Forecast and Strategic Research Report (2022 Edition)
Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
Radhat builds intranet Yum source server
Wechat applet blind box - docking wechat payment
Depth first traversal and breadth first traversal [easy to understand]