当前位置:网站首页>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;
}
};边栏推荐
- js如何将带有分割符的字符串转化成一个n维数组
- vulnhub靶场-hacksudo - Thor
- Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
- (1) CNN network structure
- vulnhub靶场-Hacker_Kid-v1.0.1
- 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
- 手机开户股票开户安全吗?那么开户需要带些什么?
- The new server is packaged with the source code of H5 mall with an operation level value of several thousand
- Report on research and investment prospects of China's silicon nitride ceramic substrate industry (2022 Edition)
- Depth first traversal and breadth first traversal [easy to understand]
猜你喜欢

What are the legal risks of NFT brought by stars such as curry and O'Neill?

There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds

Rotation order and universal lock of unity panel

Kernel stray cat stray dog pet adoption platform H5 source code

Gameframework eating guide

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
![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

vulnhub靶场-Hacker_Kid-v1.0.1

Penetration practice vulnhub range Keyring

From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
随机推荐
Wechat applet blind box - docking wechat payment
Maizeer: the two batches of products reported by the media have been taken off the shelves and sealed, and consumer appeals are accepted
Penetration practice vulnhub range Keyring
Research Report on development prediction and investment direction of nylon filament sewing thread in China (2022 Edition)
Debiasing word embeddings | talking about word embedding and deviation removal # yyds dry goods inventory #
Report on research and investment prospects of China's silicon nitride ceramic substrate industry (2022 Edition)
In depth evaluation and development trend prediction report of China's ice cream market (2022 Edition)
China PBAT resin Market Forecast and Strategic Research Report (2022 Edition)
网上股票开户安全吗?是否可靠?
From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
Equipment simulation and deduction training system software
Sword finger offer II 105 Maximum area of the island
[C supplement] [string] display the schedule of a month by date
(16) ADC conversion experiment
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
官宣!香港科技大学(广州)获批!
Unity3d extended toolbar
Smart factory digital management system software platform
Product service, operation characteristics
徽商期货是正规期货平台吗?在徽商期货开户安全吗?