Find the maximum total wealth among customers by summing each customer's bank balances.
You are given a 2D integer array accounts where accounts[i][j] is the amount of money the i-th customer has in the j-th bank.
A customer's wealth is the sum of money in all their bank accounts. Return the maximum wealth among all customers.
In other words, compute the sum of each row and return the largest row sum.
Input Format
accounts: a 2D array of non-negative integers.- Each row represents one customer.
- Each column represents one bank account for that customer.
Output Format
- Return an integer representing the richest customer's total wealth.
Constraints
1 <= accounts.length <= 1001 <= accounts[i].length <= 1000 <= accounts[i][j] <= 100
Example 1
Input
accounts = [[1,2,3],[3,2,1]]
Output
6
Explanation
The first customer has wealth 1 + 2 + 3 = 6. The second has wealth 3 + 2 + 1 = 6. The maximum wealth is 6.
Example 2
Input
accounts = [[1,5],[7,3],[3,5]]
Output
10
Explanation
Customer wealths are 6, 10, and 8. The richest customer has wealth 10.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.