当前位置:网站首页>2022.02.15 - 240. Lucky number in matrix
2022.02.15 - 240. Lucky number in matrix
2022-06-29 06:16:00 【A CAI continues to work hard】
List of articles
1. subject


2. Ideas
(1) Simulation
- ergodic matrix , Find out the minimum value of each row first , Find out the maximum value of each column , If there are duplicate elements , Indicates that the element is a lucky number .
3. Code
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Test {
public static void main(String[] args) {
}
}
class Solution {
public List<Integer> luckyNumbers(int[][] matrix) {
int m = matrix.length;
int n = matrix[0].length;
List<Integer> res = new ArrayList<>();
Set<Integer> set = new HashSet<>();
for (int i = 0; i < m; i++) {
int min = Integer.MAX_VALUE;
for (int j = 0; j < n; j++) {
min = Math.min(min, matrix[i][j]);
}
set.add(min);
}
for (int i = 0; i < n; i++) {
int max = Integer.MIN_VALUE;
for (int j = 0; j < m; j++) {
max = Math.max(max, matrix[j][i]);
}
if (!set.add(max)) {
res.add(max);
}
}
return res;
}
}
边栏推荐
- Principle of screen printing adjustment of EDA (cadence and AD) software
- Servlet version conflict causes page 404
- Fault: administrator account cannot be selected for login
- Convert data frame with date column to timeseries
- What is MES? What does it do?
- MySQL add / delete / modify query SQL statement exercise yyds dry goods inventory
- Plugin
- Hyperledger Fabric 2. X custom smart contract
- [deep learning] - maze task learning I (to realize the random movement of agents)
- Design risc-v processor from scratch -- data adventure of five stage pipeline
猜你喜欢

Difference between parametric continuity and geometric continuity

Modularization and modular specification commonjs

Hyperledger Fabric 2. X custom smart contract

Purple red solid meso tetra (o-alkoxyphenyl) porphyrin cobalt (meso-t (2-rop) PCO) / tetra (n, n-diphenyl-p-amino) phenyl porphyrin (tdpatph2)
![[C language series] - branch and loop statements](/img/bf/656c9189b4ab4387c5acab1c4a2804.jpg)
[C language series] - branch and loop statements

The most complete machine learning model training process
![[C language series] - initial C language (4)](/img/3b/b20d6e0194f2114f8c27a17d58369a.jpg)
[C language series] - initial C language (4)

51 single chip microcomputer learning notes 7 -- Ultrasonic Ranging

Establishing the development environment of esp8266
![[high concurrency] deeply analyze the callable interface](/img/fb/89ebd5592f1383c8015a47cec78a59.jpg)
[high concurrency] deeply analyze the callable interface
随机推荐
Fault: KDC warning log for id29
2022 recommended high-speed rail industry research report investment strategy industry development prospect market analysis (the attachment is a link to the online disk, and the report is continuously
About: deleting unwanted event log lists
ES6 Modularization: export /import
Difference between URI and URL
β- Tetraphenyl nickel porphyrin with all chlorine substitution| β- Thiocyano tetraphenyl porphyrin copper| β- Dihydroxy tetraphenyl porphyrin 𞓜 2-nitroporphyrin | supplied by Qiyue
Programming specification and variables of shell script
ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
What if the hard disk fails to recognize how to recover data
Establishing the development environment of esp8266
DANGER! V** caught climbing over the wall!
Ctrip launched the "3+2" office mode. Are you sour?
64 commonly used terms for data analysis, really all!
Fault: NetBt log for id4321
Spark saving to external data source
Convert data frame with date column to timeseries
Why can't the article be posted?
What has urbanization brought to our mental health and behavior?
Leetcode theme [array] -217- there are duplicate elements
5- (4-benzoimide phenyl) - 10,15,20-triphenylporphyrin (battph2) and its Zn complex (battpzn) / tetra (4-aminophenyl) porphyrin (tapph2) Qiyue supply