Skip to main content
Back to problems
Leetcode
Easy
Arrays
Math
Richest Customer Wealth

Find the maximum total wealth among customers by summing each customer's bank balances.

Acceptance 100%
Problem Statement

You are given a 2D integer array accounts where accounts[i][j] is the amount of money the i-th customer has in the j-th bank.

A customer's wealth is the sum of money in all their bank accounts. Return the maximum wealth among all customers.

In other words, compute the sum of each row and return the largest row sum.

Input Format

  • accounts: a 2D array of non-negative integers.
  • Each row represents one customer.
  • Each column represents one bank account for that customer.

Output Format

  • Return an integer representing the richest customer's total wealth.

Constraints

  • 1 <= accounts.length <= 100
  • 1 <= accounts[i].length <= 100
  • 0 <= accounts[i][j] <= 100
Examples
Sample cases returned by the problem API.

Example 1

Input

accounts = [[1,2,3],[3,2,1]]

Output

6

Explanation

The first customer has wealth 1 + 2 + 3 = 6. The second has wealth 3 + 2 + 1 = 6. The maximum wealth is 6.

Example 2

Input

accounts = [[1,5],[7,3],[3,5]]

Output

10

Explanation

Customer wealths are 6, 10, and 8. The richest customer has wealth 10.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.