This commit is contained in:
parent
ea63f9a6c6
commit
6669e03a5e
1 changed files with 15 additions and 0 deletions
15
easy/lucky_numbers_in_a_matrix.py
Normal file
15
easy/lucky_numbers_in_a_matrix.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# https://leetcode.com/problems/lucky-numbers-in-a-matrix
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
class Solution:
|
||||||
|
def luckyNumbers (self, matrix: List[List[int]]) -> List[int]:
|
||||||
|
ret: List[int] = []
|
||||||
|
cols: List[int] = list(map(max, zip(*matrix)))
|
||||||
|
i = 0
|
||||||
|
while i < len(matrix):
|
||||||
|
min_index, min_value = min(enumerate(matrix[i]), key=lambda x: x[1])
|
||||||
|
if cols[min_index] == min_value:
|
||||||
|
ret.append(min_value)
|
||||||
|
i += 1
|
||||||
|
return ret
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue