[LeetCode]#1380. Lucky Numbers in a Matrix

Input: matrix = [[3,7,8],[9,11,13],[15,16,17]]
Output: [15]
Explanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column
class Solution:
def luckyNumbers (self, matrix):
min_n = {min(rows) for rows in matrix}
max_n = {max(columns) for columns in zip(*matrix)}

return list(min_n & max_n)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store