LeetCode #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