Skip to content

Commit ff6eea9

Browse files
committed
Richest Customer Wealth
1 parent 50afda3 commit ff6eea9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

1672-ichest-customer-wealth.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Problem Link: https://leetcode.com/problems/richest-customer-wealth/
3+
4+
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.
5+
Return the wealth that the richest customer has.
6+
A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that
7+
has the maximum wealth.
8+
9+
Example 1:
10+
Input: accounts = [[1,2,3],[3,2,1]]
11+
Output: 6
12+
Explanation:
13+
1st customer has wealth = 1 + 2 + 3 = 6
14+
2nd customer has wealth = 3 + 2 + 1 = 6
15+
Both customers are considered the richest with a wealth of 6 each, so return 6.
16+
17+
Example 2:
18+
Input: accounts = [[1,5],[7,3],[3,5]]
19+
Output: 10
20+
Explanation:
21+
1st customer has wealth = 6
22+
2nd customer has wealth = 10
23+
3rd customer has wealth = 8
24+
The 2nd customer is the richest with a wealth of 10.
25+
26+
Example 3:
27+
Input: accounts = [[2,8,7],[7,1,3],[1,9,5]]
28+
Output: 17
29+
30+
Constraints:
31+
m == accounts.length
32+
n == accounts[i].length
33+
1 <= m, n <= 50
34+
1 <= accounts[i][j] <= 100
35+
"""
36+
class Solution:
37+
def maximumWealth(self, accounts: List[List[int]]) -> int:
38+
max_sum = 0
39+
for account in accounts:
40+
max_sum = max(max_sum, sum(account))
41+
42+
return max_sum

0 commit comments

Comments
 (0)