Imagine you're a bank analyst tasked with identifying the wealthiest customer across multiple banking institutions. You have access to a comprehensive financial report represented as a matrix where each row represents a customer and each column represents a different bank.
Given an m x n integer matrix accounts where accounts[i][j] represents the amount of money the ith customer has in the jth bank, your goal is to find the maximum total wealth among all customers.
A customer's wealth is calculated as the sum of all money they have across all their bank accounts. Return the wealth of the richest customer.
Example: If customer 0 has [1, 2, 3] in three banks, their total wealth is 1 + 2 + 3 = 6.
Input & Output
Visualization
Time & Space Complexity
We visit each element in the matrix exactly once, where m is customers and n is banks
Only using a few variables to track current and maximum wealth
Constraints
- m == accounts.length
- n == accounts[i].length
- 1 โค m, n โค 50
- 1 โค accounts[i][j] โค 100