[LeetCode]#1672. Richest Customer Wealth

Input: accounts = [[1,2,3],[3,2,1]]
Output: 6
Explanation:
1st customer has wealth = 1 + 2 + 3 = 6
2nd customer has wealth = 3 + 2 + 1 = 6
Both customers are considered the richest with a wealth of 6 each, so return 6.
Input: accounts = [[1,5],[7,3],[3,5]]
Output: 10
Explanation:
1st customer has wealth = 6
2nd customer has wealth = 10
3rd customer has wealth = 8
The 2nd customer is the richest with a wealth of 10.
Input: accounts = [[2,8,7],[7,1,3],[1,9,5]]
Output: 17
  1. Sum list a, b, c
  2. Find the largest one.
class Solution:
def maximumWealth(self, accounts):
ans, curr= 0, 0
for i in accounts:
for j in i:
curr+=j
ans=max(ans,curr)
curr=0
return ans

Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Choosing which Flavour of BDD framework to use

2020 Programming Trend Predictions

Learning PowerShell — Let’s Do It Together — Part 3

Flux 2022 goals — Non-code tech skills.

CI/CD for AWS EKS

CS371p: Week 7

Azure Multi-Stage Pipeline for Asp.Net Core and Azure, Deploy to Azure App Service

Install Jenkins on Amazon Linux 2 instance:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fatboy Slim

Fatboy Slim

Interesting in any computer science.

More from Medium

Hi all, attached below is the code demo for a Hackerrank that I recently attempted.

[LeetCode] 260. Single Number III

Remove nth node from end of list Leetcode Python

LeetCode Patterns Adventure 20— Average of Levels in Binary Tree