Magicsheet logo

Richest Customer Wealth

Easy
25%
Updated 8/1/2025

Richest Customer Wealth

What is this problem about?

The Richest Customer Wealth interview question gives you a 2D integer array where accounts[i][j] is the amount of money the i-th customer has in the j-th bank. The total wealth of a customer is the sum of their bank account balances. Return the maximum wealth among all customers.

Why is this asked in interviews?

This problem is asked at Microsoft, Meta, Amazon, Google, Bloomberg, and Adobe as an entry-level matrix traversal warm-up. It tests basic 2D array iteration, row summation, and global maximum tracking — foundational skills in data analysis, financial reporting, and any domain involving tabular numeric data. Despite its simplicity, it validates correct loop nesting and Python's built-in sum() and max() usage.

Algorithmic pattern used

The pattern is row-wise summation with global max tracking. For each row (customer), compute the sum of all elements. Track the maximum sum seen so far. In Python: max(sum(row) for row in accounts). In other languages, use a nested loop: outer loop over customers, inner loop over accounts, accumulate sum, update global max. This is O(m × n) time and O(1) extra space.

Example explanation

Accounts:

[[1, 5],
 [7, 3],
 [3, 5]]

Customer 0 wealth: 1 + 5 = 6. Customer 1 wealth: 7 + 3 = 10. Customer 2 wealth: 3 + 5 = 8.

Maximum wealth: 10 (customer 1).

Accounts:

[[2, 8, 7],
 [7, 1, 3],
 [1, 9, 5]]

Sums: 17, 11, 15. Max: 17.

Common mistakes candidates make

  • Summing the wrong dimension — summing column-wise instead of row-wise.
  • Forgetting to reset the row sum between customers in a manual loop implementation.
  • Not initializing the max correctly — start at 0 or float('-inf') to handle negative balances.
  • Using a nested loop incorrectly when Python's sum() makes it clean and concise.

Interview preparation tip

For the Richest Customer Wealth coding problem, the array and matrix interview pattern is the simplest possible: iterate over rows, sum each, track max. In Python, a one-liner max(sum(row) for row in accounts) is perfectly acceptable and preferred for its clarity. Interviewers at Microsoft and Google use this as a 2-minute warm-up — solve it fast and offer to discuss extending it (e.g., "return the customer index, not just the wealth").

Similar Questions