15 lines
497 B
Python
15 lines
497 B
Python
# 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
|
|
|