# 1672. Richest Customer Wealth ## [題目:](https://leetcode.com/problems/number-of-good-pairs/) 給定一個二維陣列,找出相加為最大陣列並算出值來 這些值分別代表著客戶及他們每一家的銀行存款,並從中找出最有錢的人擁有的資金 ex:`[[1,2,3],[3,2,1]]` 1+2+3 vs 3+2+1 都是6,所以輸出為`6` ## 思路 一個個累加帳號所有銀行內的錢,挑出最大值 ```go= func maximumWealth(accounts [][]int) int { var maxWealth = 0 for _, account := range accounts { var wealth = 0 for _, bank := range account { wealth += bank } if maxWealth < wealth { maxWealth = wealth } } return maxWealth } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up