当前位置:网站首页>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

边栏推荐
- 二、mock平台的扩展
- 2322. 从树中删除边的最小分数(异或和&模拟)
- Just a coincidence? The mysterious technology of apple ios16 is even consistent with the products of Chinese enterprises five years ago!
- 亚马逊云科技 Community Builder 申请窗口开启
- 剑指 Offer 26. 树的子结构
- 871. Minimum refueling times
- 社交元宇宙平台Soul冲刺港股:年营收12.8亿 腾讯是股东
- Talk about an experience of job hopping and being rejected
- 超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业
- 学习周刊-总第60期-2022年第25周
猜你喜欢
![[error record] error -32000 received from application: there are no running service protocol](/img/6c/66099650de46cac88b805e6cfb90b9.jpg)
[error record] error -32000 received from application: there are no running service protocol

寒门再出贵子:江西穷县考出了省状元,做对了什么?

TCP拥塞控制详解 | 2. 背景

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

Tech Talk 活动预告 | 基于Amazon KVS打造智能视觉产品

剑指 Offer 21. 调整数组顺序使奇数位于偶数前面

Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)

OpenPose的使用

深度之眼(三)——矩阵的行列式

剑指 Offer 26. 树的子结构
随机推荐
【Leetcode】14. Longest Common Prefix
Does digicert SSL certificate support Chinese domain name application?
Blog theme "text" summer fresh Special Edition
Connect Porsche and 3PL EDI cases
七张图,学会做有价值的经营分析
剑指 Offer 25. 合并两个排序的链表
JS delete substring in string
Deep learning image data automatic annotation [easy to understand]
IPtables中SNAT、DNAT和MASQUERADE的含义
The macrogenome microbiome knowledge you want is all here (2022.7)
How to transfer business data with BorgWarner through EDI?
入行数字IC验证后会做些什么?
lsf基础命令
&lt; IV & gt; H264 decode output YUV file
AP and F107 data sources and processing
P6774 [NOI2020] 时代的眼泪(分块)
uboot的作用和功能
相信自己,这次一把搞定JVM面试
Cell:清华程功组揭示皮肤菌群的一种气味挥发物促进黄病毒感染宿主吸引蚊虫...
Interpretation of key parameters in MOSFET device manual