Skip to main content

1672. Richest Customer Wealth

Python

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

Go

func maximumWealth(accounts [][]int) int {
max := 0
for _, wealths := range accounts {
total := sum(wealths)
if (total > max) {
max = total
}
}
return max
}

func sum(list []int) int {
total := 0
for _, v := range list {
total += v
}
return total
}