37. Richest Customer Wealth

EasyArrayArray

You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i-th customer has in the j-th bank. Return the wealth of the richest customer (the customer with the maximum total across all banks).

Input: A 2D integer array accounts of size m x n.

Output: Integer — total wealth of the richest customer.

Examples

Example 1
Input: [[1,2,3],[3,2,1]]
Output: 6
Explanation: Customer 1: 1+2+3=6. Customer 2: 3+2+1=6. Both richest with 6.
Example 2
Input: [[1,5],[7,3],[3,5]]
Output: 10
Explanation: Customer 1: 6. Customer 2: 10. Customer 3: 8. Max=10.
Example 3
Input: [[2,8,7],[7,1,3],[1,9,5]]
Output: 17
Explanation: Customer 1: 17. Customer 2: 11. Customer 3: 15. Max=17.

Constraints

Asked by

GoogleMicrosoftMetaBloombergAmazon
Solve this problem in the editor →