当前位置:网站首页>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;
}
};
边栏推荐
- 面试题 16.16. 部分排序-双指针法
- MySQL reports an error can't create table 'demo01 tb_ Student‘ (errno: 150)*
- mysql 报错 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
- Basic knowledge of audio coding and decoding
- Oracle物理体系结构
- IPv4 address, subnet mask, gateway
- 703. The k-th element in the data flow
- 【无标题】
- JVM内存模型
- ModSim基本使用(Modbus模拟器)
猜你喜欢
Introduction to relevant processes and functions of wechat official account development
A brief understanding of white box encryption technology
What is the essential difference between Bi development and report development?
Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?
Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
数字化转型企业成功的关键,用数据创造价值
Audio and video, encoding and decoding related e-books, gadgets, packaged for free!
HLS4ML报错The board_part definition was not found for tul.com.tw:pynq-z2:part0:1.0.
产品模块化设计的前世今生
GC garbage collection
随机推荐
optaplanner学习笔记(一)案例Cloud balance
Thesis reading [distinctive late semantic graph for video capturing]
[info() method in org.slf4j.logger]
IPv4地址、子网掩码、网关
Axure does not display catalogs
Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
After studying 11 kinds of real-time chat software, I found that they all have these functions
GB28181的NAT穿透
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
Why must we move from Devops to bizdevops?
What is the essential difference between Bi development and report development?
pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
[English grammar] Unit1 articles, nouns, pronouns and numerals
2022/6/8-2022/6/12
面试题 16.16. 部分排序-双指针法
再回顾集合容器
研究了11种实时聊天软件,我发现都具备这些功能…
Learning records of building thingsboard, an Internet of things platform
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
Opencv video quality detection -- sharpness detection