728x90
The LeetCode Beginner's Guide의 Challenge Problems에서 2번째로 나온 문제.
큰 리스트 안에 작은 리스트가 여러 개 있고, 리스트의 합을 비교하면 되는 문제
class Solution(object):
def maximumWealth(self, accounts):
"""
:type accounts: List[List[int]]
:rtype: int
"""
answ = []
for i, j in enumerate(accounts):
a = sum(j)
answ.append(a)
return max(answ)
1. 빈 list인 answ를 새로 만들고
2. j로 받은 작은 리스트의 합 값을 a로 취한 뒤
3. answ list에 하나씩 추가
4. amsw list의 max 값을 return
728x90
'코딩 공부 > Leetcode' 카테고리의 다른 글
[Python] 412. Fizz Buzz (0) | 2025.01.10 |
---|---|
[Python] 2381. Shifting Letters II (0) | 2025.01.09 |
[Python] 2185. Counting Words With a Given Prefix (0) | 2025.01.09 |
[Python] 3042. Count Prefix and Suffix Pairs I (0) | 2025.01.08 |
[Python] 1480. Running Sum of 1d Array (0) | 2025.01.08 |