본문 바로가기
python-algorithm

leetcode 1380. Lucky Numbers in a Matrix

by 무적김두칠 2022. 3. 22.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution:
    def luckyNumbers (self, matrix: List[List[int]]) -> List[int]:
        rowMin = []
        colMax=[]
        ans=[]
        for i in matrix:
            rowMin.append(min(i))
        for j in range(len(matrix[0])):
            tmpCol=[]
            for i in range(len(matrix)):
                tmpCol.append(matrix[i][j])
            colMax.append(max(tmpCol))
        for i in rowMin:
            if i in colMax: ans.append(i)
        return ans
cs
반응형

댓글