티스토리 뷰

반응형

 

 

 

나의코드

class Solution:
    def maximumWealth(self, accounts: List[List[int]]) -> int:
        array=[]
        for i in range(0,len(accounts)):
            result = 0
            for l in range(0, len(accounts[i]) ):
                result += accounts[i][l]
            array.append(result)
        return max(array)

 

 

더 간결한 코드

class Solution:
    def maximumWealth(self, accounts: List[List[int]]) -> int:
        return max(sum(customer) for customer in accounts)

 

 

*유의사항 

sum(account for account in accounts) 는 [1,2,3,1,2,3] 이고,

sum(account) for account in accounts 는 각각 6,6

반응형

'LeetCode' 카테고리의 다른 글

[LeetCode/Python] 412. Fizz Buzz  (0) 2025.05.12
[LeetCode/Python] 1480. Running Sum of 1d Array  (0) 2025.05.10
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/08   »
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
글 보관함