Richest Customer Wealth

You are given an m x n grid `accounts` where `accounts[i][j]` is the money customer i keeps in bank j. A customer's wealth is the total across all of their banks. Return the wealth of the richest customer.

30:00

Richest Customer Wealth
easy
Free written solution
Topics
Companies

You are given an m x n grid accounts where accounts[i][j] is the money customer i keeps in bank j. A customer's wealth is the total across all of their banks. Return the wealth of the richest customer.

Example 1:
Input: {"accounts":[[1,2,3],[3,2,1]]}
Output: 6
Constraints:
  • m==accounts.lengthm == \text{accounts.length}

  • n==accounts[i].lengthn == \text{accounts}[i].\text{length}

  • 1≤m,n≤501 \leq m, n \leq 50

  • 1≤accounts[i][j]≤1001 \leq \text{accounts}[i][j] \leq 100

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"accounts":[[1,2,3],[3,2,1]]}

best starts at 0. We will total each of the 2 customers and keep the largest total.

accounts: rows are customers, columns are banks

C0

1
2
3

C1

3
2
1

wealth

-

best so far

0

wealth per customer (the line marks best)

C0

?

C1

?

Variables
VariableValue
best0
DepthFunction Call
Stack empty
0/13