Menu
CoddyTech

Richest Customer Wealth

A bank keeps a grid accounts with m rows, one per customer, and n columns, one per bank: accounts[i][j] is the money customer i holds in bank j. A customer's wealth is the total of their row. Return the wealth of the richest customer.

Function

maximumWealth(accounts: integer-2d-array) → integer
accountsinteger-2d-array
the grid of balances, one row per customer and one column per bank
Returnsinteger
the largest row total

Constraints

  • 1 ≤ accounts.length ≤ 100
  • 1 ≤ accounts[i].length ≤ 100, and every row has the same length.
  • 0 ≤ accounts[i][j] ≤ 104

Examples

Input
accounts = [[2, 8, 1], [5, 5, 4], [7, 0, 3]]
Output
14
Explanation
The rows add up to 2 + 8 + 1 = 11, 5 + 5 + 4 = 14 and 7 + 0 + 3 = 10. The middle customer has the most, 14, even though the single largest balance, 8, belongs to someone else.

lock icon+14 hidden tests on Submit

Reset code
def maximumWealth(accounts):
    # Write code here
Test cases

Case 1

Case 2

Input

accounts = [[2, 8, 1], [5, 5, 4], [7, 0, 3]]

Expected

14