Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 릿코드풀이
- python zip_longest
- 잇츠디모
- 파이썬 알고리즘 풀기
- python Leetcode
- 상가수익률계산기
- leetcode풀이
- 파이썬 알고리즘
- LeetCode
- python sorted
- python xor
- python 알고리즘
- 파이썬 프로그래머스
- 파이썬릿코드
- python priority queue
- 파이썬 릿코드
- 릿코드
- leetcode 풀기
- 코틀린기초
- 릿코드 파이썬
- 파이썬릿코드풀기
- binary search
- 릿코드 풀기
- 릿코드풀기
- 알고리즘풀기
- 파이썬알고리즘
- 파이썬알고리즘풀기
- python 릿코드
- leetcode풀기
- 알고리즘풀이
Archives
- Today
- Total
소프트웨어에 대한 모든 것
LeetCode 풀기 - 1380. Lucky Numbers in a Matrix 본문
반응형
1380. Lucky Numbers in a Matrix
https://leetcode.com/problems/lucky-numbers-in-a-matrix/
Lucky Numbers in a Matrix - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제)
솔루션1)
class Solution:
def luckyNumbers (self, matrix: List[List[int]]) -> List[int]:
n_row = len(matrix)
n_col = len(matrix[0])
mins = []
for i in range(n_row):
mins.append(min(matrix[i]))
matrix = list(zip(*matrix))
maxs = []
for i in range(n_col):
maxs.append(max(matrix[i]))
return list(set(mins) & set(maxs))
솔루션2)
솔루션1 코드 축약 버전
class Solution:
def luckyNumbers (self, matrix: List[List[int]]) -> List[int]:
mins = {min(row) for row in matrix}
maxs = {max(col) for col in zip(*matrix)}
return mins & maxs
반응형
'알고리즘 > LeetCode' 카테고리의 다른 글
LeetCode 풀기 - 559. Maximum Depth of N-ary Tree (0) | 2021.12.31 |
---|---|
LeetCode 풀기 - 1356. Sort Integers by The Number of 1 Bits (0) | 2021.12.29 |
LeetCode 풀기 - 227. Basic Calculator II (0) | 2021.12.28 |
540. Single Element in a Sorted Array (0) | 2021.12.28 |
LeetCode 풀기 - 973. K Closest Points to Origin (0) | 2021.12.26 |
Comments