当前位置:网站首页>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;
}
};
边栏推荐
- [Mori city] random talk on GIS data (I)
- Interview questions for audio and video positions in Dachang -- today's headline
- Shell advanced
- 大厂音视频职位面试题目--今日头条
- Wechat applet navigator has a shadow after clicking. Remove the shadow effect of navigator
- Werewolf killing strategy: do you think I'm easy to cheat? Who do we believe!
- Anaconda安装虚拟环境到指定路径
- 【let var const】
- 【sql优化】with as 和 临时表的区别
- HLS4ML/vivado HLS 报错解决方案
猜你喜欢

Object creation

118. Yanghui triangle

HLS4ML报错The board_part definition was not found for tul.com.tw:pynq-z2:part0:1.0.

MySQl的基本使用

GB28181之SIP协议

After studying 11 kinds of real-time chat software, I found that they all have these functions

Summary of SQL query de duplication statistics methods

118. 杨辉三角
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
![[Mori city] random talk on GIS data (I)](/img/4d/1ed4bbf397b8d756c91241705528de.jpg)
[Mori city] random talk on GIS data (I)
随机推荐
博途V16 获取系统时间转换成字符串
ffmpeg 音频相关命令
Facebook聊单,SaleSmartly有妙招!
Object creation
Simplified pinduoduo product data
Ffmpeg error code
产品模块化设计的前世今生
Time series analysis using kibana timelion
mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
ffmpeg AVFrame 转 cv::Mat
brpc理解
Collect Tiktok video
ffmpeg 错误码
Shell高级进阶
解决VSCode下载慢或下载失败的问题
Optaplanner learning notes (I) case cloud balance
Uni app product classification
Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits
SIP protocol of gb28181
再回顾集合容器