Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Problem 1: Richest Customer Wealth (easy)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

You are given an m x n matrix accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank.

Return the wealth that the richest customer has.

Imagine every customer has multiple bank accounts, with each account holding a certain amount of money. The total wealth of a customer is calculated by summing all the money across all their multiple.

Examples

  1. Example 1:

    • Input: accounts =
      [[5,2,3],
       [0,6,7]]
      
    • Expected Output: 13
    • Justification: The total wealth of the first customer is 10 and of the second customer is 13. So, the output is 13 as it's the maximum among all customers.
  2. Example 2:

    • Input: accounts =
      [[1,2],
       [3,4],
       [5,6]]
      
    • Expected Output: 11
    • Justification: Total wealth for each customer is [3, 7, 11]. Maximum of these is 11.
  3. Example 3:

    • Input: accounts =
     [[5,10,15],
      [10,20,30],
      [15,30,45]]
    
    • Expected Output: 90
    • Justification: Total wealth for each customer is [30, 60, 90]. The wealthiest customer has 90.

Constraints:

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

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible