You are given an m x n integer grid called accounts, where each row represents a customer and each element in the row is the amount of money they have in one bank account. The wealth of a customer is the total sum of money they have across all their accounts.
Return the wealth of the richest customer, that is, the highest total wealth among all customers.
Function Signature
def maximum_wealth(accounts: list[list[int]]) -> int:
Constraints
-
m == accounts.length
-
n == accounts[i].length
-
1 <= m, n <= 75
-
1 <= accounts[i][j] <= 75
Examples
Input: accounts = [[2, 3, 4], [4, 3, 2]]
Output: 9
The first customer has 2 + 3 + 4 = 9 and the second has 4 + 3 + 2 = 9. Both customers have a wealth of 9, so the output is 9.
Input: accounts = [[3, 6], [8, 4], [4, 6]]
Output: 12
The customers have 3 + 6 = 9, 8 + 4 = 12 and 4 + 6 = 10. The second customer is the richest with a wealth of 12.
Input: accounts = [[1, 4, 5], [6, 2, 7], [3, 9, 6]]
Output: 18
The customers have 1 + 4 + 5 = 10, 6 + 2 + 7 = 15 and 3 + 9 + 6 = 18. The third customer is the richest with a wealth of 18.