코딩 공부/Leetcode

[Python] 1672. Richest Customer Wealth

일하는 공학도 2025. 1. 9. 10:20
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