The smallest of all elements in the same row
The largest of all elements in the same column
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 .
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 .
Input :matrix = [[7,8],[1,2]]
Output :[7]
m == mat.length
n == mat[i].length
1 <= n, m <= 50
1 <= matrix[i][j] <= 10^5
All elements in the matrix are different
class Solution:
def luckyNumbers (self, matrix: List[List[int]]) -> List[int]:
ans = []
for i in matrix:
for j, x in enumerate(i):
if x == min(i) and x == max(k[j] for k in matrix):
ans.append(x)
return ans
Catalog 1 First import some pa