当前位置:网站首页>LeetCode:1380. Lucky number in matrix -- simple
LeetCode:1380. Lucky number in matrix -- simple
2022-07-02 17:17:00 【Kinght_ one hundred and twenty-three】
subject
1380. The lucky number in the matrix
To give you one m * n Matrix , The number in the matrix Each are not identical . Please press arbitrarily Return all the lucky numbers in the matrix in order .
Lucky number refers to the elements in the matrix that meet the following two conditions at the same time :
- The smallest of all elements in the same row
- The largest of all elements in the same column
Example 1:
Input :matrix = [[3,7,8],[9,11,13],[15,16,17]]
Output :[15]
explain :15 Is the only lucky number , Because it is the smallest value in its row , It is also the maximum value in the column .
Example 2:
Input :matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]]
Output :[12]
explain :12 Is the only lucky number , Because it is the smallest value in its row , It is also the maximum value in the column .
Example 3:
Input :matrix = [[7,8],[1,2]]
Output :[7]
Tips :
- m == mat.length
- n == mat[i].length
- 1 <= n, m <= 50
- 1 <= matrix[i][j] <= 10^5
- All elements in the matrix are different
Their thinking
- simulation .
Code
class Solution:
def luckyNumbers (self, matrix: List[List[int]]) -> List[int]:
ans = []
for nums in matrix:
for i in range(len(nums)):
if nums[i] == min(nums) and nums[i] == max(sit[i] for sit in matrix):
ans.append(nums[i])
return ans
Running results

边栏推荐
- Role and function of uboot
- What is the difference between JSP and servlet?
- [cloud native] briefly talk about the understanding of flume, a massive data collection component
- VMware安装win10镜像
- LSF basic command
- Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
- 使用知行之桥的API端口,提供资源供合作伙伴访问
- C语言中sprintf()函数的用法
- 关于举办科技期刊青年编辑沙龙——新时代青年编辑应具备的能力及提升策略的通知...
- 2022 interview questions
猜你喜欢

超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业

MOSFET器件手册关键参数解读

剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
![[cloud native] briefly talk about the understanding of flume, a massive data collection component](/img/2d/8c4769e97fb84e98eafb7069551341.png)
[cloud native] briefly talk about the understanding of flume, a massive data collection component

OpenPose的使用

Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))

易语言abcd排序

Sword finger offer 22 The penultimate node in the linked list

绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东

Exploration of mobile application performance tools
随机推荐
lsf基础命令
Just a coincidence? The mysterious technology of apple ios16 is even consistent with the products of Chinese enterprises five years ago!
体验居家办公完成项目有感 | 社区征文
绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
使用知行之桥的API端口,提供资源供合作伙伴访问
Talk about an experience of job hopping and being rejected
Blog theme "text" summer fresh Special Edition
Cell:清华程功组揭示皮肤菌群的一种气味挥发物促进黄病毒感染宿主吸引蚊虫...
[cloud native] briefly talk about the understanding of flume, a massive data collection component
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition (a sign in, B sign in, C sign in, D thinking +mst
&lt; IV & gt; H264 decode output YUV file
Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
In MySQL and Oracle, the boundary and range of between and precautions when querying the date
远程办公对我们的各方面影响心得 | 社区征文
ThreadLocal
DGraph: 大规模动态图数据集
配置基于接口的ARP表项限制和端口安全(限制用户私自接入傻瓜交换机或非法主机接入)
默认浏览器设置不了怎么办?