Richest Customer Wealth

Easy · Matrix · Array · Matrix

Problem

You are given an m x n integer grid accounts, where accounts[i][j] is the amount customer i holds at bank j. A customer's wealth is the total across all of their bank accounts.

Return the wealth of the richest customer.

Examples

Input: accounts = [[2,7,1],[4,4,4]]
Output: 12

The customers hold 10 and 12, so the answer is 12.

Input: accounts = [[5],[9],[3]]
Output: 9

With a single bank, wealth is that one amount: 9 is the largest.

Input: accounts = [[1,5],[3,3],[2,4]]
Output: 6

All three customers hold 6.

Constraints

Approaches

Follow-up

Rows are customers and columns are banks, so the same grid answers other questions with the same loop in a different direction. The use cases find which customer is richest and which bank holds the most money.

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…