LeetCode #1672. Richest Customer Wealth

题目

1672. Richest Customer Wealth


解题方法

设置一个最大财富值,遍历数组用sum计算每个顾客的财富,找到最大值即可。
时间复杂度:O(n)
空间复杂度:O(1)


代码

class Solution:
    def maximumWealth(self, accounts: List[List[int]]) -> int:
        maxwealth = 0
        for customer in accounts:
            maxwealth = max(maxwealth, sum(customer))
        return maxwealth
posted @ 2020-12-04 13:49  老鼠司令  阅读(163)  评论(0编辑  收藏  举报