Find the Largest Customer Account Total

Quick Overview

Find the Largest Customer Account Total. In matrix accounts, a row contains one customer’s balances across the banks. Add each customer’s balances and return the largest of those totals.

Find the Largest Customer Account Total

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem In matrix `accounts`, a row contains one customer’s balances across the banks. Add each customer’s balances and return the largest of those totals. ```cpp class Solution { public: int maximumWealth(vector<vector<int>>& accounts); }; ``` ### Examples **Example 1:** ```text accounts = [[2,3],[1,7],[4,2]] Output: 8 Explanation: The row totals are 5, 8, and 6. ``` **Example 2:** ```text accounts = [[6,1,2],[3,3,3]] Output: 9 Explanation: Both customers have total balance 9. ``` ### Constraints - `m == accounts.length`, `n == accounts[i].length`. - `1 <= m,n <= 50`. - `1 <= accounts[i][j] <= 100`. ### Clarifying Questions Return the greatest total balance, not a customer index or the greatest individual account balance. ```hint Inspect the structure Which balances belong to the same customer, and what quantity must the function return? ``` ### Reasoning checkpoints - Sum by customer rows. - Retain the maximum completed row total. ### Optional extensions How would you return every customer tied for the greatest total?

Overview: Find the Largest Customer Account Total. In matrix accounts, a row contains one customer’s balances across the banks. Add each customer’s balances and return the largest of those totals.

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

In matrix accounts, a row contains one customer’s balances across the banks. Add each customer’s balances and return the largest of those totals.

class Solution {
public:
    int maximumWealth(vector<vector<int>>& accounts);
};

Examples

Example 1:

accounts = [[2,3],[1,7],[4,2]]
Output: 8
Explanation: The row totals are 5, 8, and 6.

Example 2:

accounts = [[6,1,2],[3,3,3]]
Output: 9
Explanation: Both customers have total balance 9.

Constraints

  • m == accounts.length , n == accounts[i].length .
  • 1 <= m,n <= 50 .
  • 1 <= accounts[i][j] <= 100 .

Clarifying Questions Guidance

Return the greatest total balance, not a customer index or the greatest individual account balance.

Reasoning checkpoints

  • Sum by customer rows.
  • Retain the maximum completed row total.

Optional extensions

How would you return every customer tied for the greatest total?