当前位置:网站首页>Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
2022-07-01 19:43:00 【HERODING23】

Their thinking :
Use two arrays to count the minimum number in each row and the maximum number in each column , The code is as follows :
class Solution {
public:
vector<int> luckyNumbers (vector<vector<int>>& matrix) {
vector<int> res;
int m = matrix.size();
int n = matrix[0].size();
vector<int> row(m, INT_MAX);
vector<int> col(n, 0);
for(int i = 0; i < m; i ++) {
for(int j = 0; j < n; j ++) {
if(matrix[i][j] < row[i]) {
row[i] = matrix[i][j];
}
if(matrix[i][j] > col[j]) {
col[j] = matrix[i][j];
}
}
}
for(int i = 0; i < m; i ++) {
for(int j = 0; j < n; j ++) {
if(matrix[i][j] == row[i] && matrix[i][j] == col[j]) {
res.push_back(matrix[i][j]);
}
}
}
return res;
}
};
边栏推荐
- 1592 例题1 国王(Sgu223 LOJ10170 LUOGU1896 提高+/省选-) 暴力思考 状压DP 01背包
- Botu V16 obtains the system time and converts it into a string
- GC garbage collection
- Collation of open source protocols of open source frameworks commonly used in Web Development
- Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
- 面试题 16.16. 部分排序-双指针法
- OpenCV视频质量诊断----视频遮挡诊断
- Live HLS protocol
- How to configure webrtc video streaming format for easygbs, a new version of national standard gb28181 video platform?
- CMU AI PhD first year summary
猜你喜欢

再回顾集合容器

正则表达式=Regex=regular expression

How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?

测试自学人必看:软件测试如何找测试项目?

音视频、编解码相关电子书、小工具,打包奉送!

Why must we move from Devops to bizdevops?

Optaplanner learning notes (I) case cloud balance

【AI服务器搭建】CUDA环境
![[Mori city] random talk on GIS data (I)](/img/4d/1ed4bbf397b8d756c91241705528de.jpg)
[Mori city] random talk on GIS data (I)

Uni app wechat applet one click login to obtain permission function
随机推荐
Introduction to relevant processes and functions of wechat official account development
[SQL optimization] the difference between with as and temporary tables
宝,运维100+服务器很头疼怎么办?用行云管家!
较真儿学源码系列-InheritableThreadLocal(逐行源码带你分析作者思路)
js三元表达式复杂条件判断
Ffmpeg audio related commands
Proxy in ES6
Oracle物理体系结构
118. 杨辉三角
Optimization of video streaming with repeated requests in the case of unstable easygbs network
torch. nn. functional. Interpolate function
Object creation
JS ternary expression complex condition judgment
Anaconda安装虚拟环境到指定路径
Download (export) PDF template file (such as approval form), and report error: invalid nested tag * * * found, expected closing tag***
商业智能BI开发和报表开发有什么本质区别?
Ffmpeg common commands (2)
MySQl的基本使用
[Mori city] random talk on GIS data (I)
Basic use of MySQL