当前位置:网站首页>1672. 最富有客户的资产总量
1672. 最富有客户的资产总量
2022-07-04 17:39:00 【charlsdm】
- 最富有客户的资产总量
给你一个 m x n 的整数网格 accounts ,其中 accounts[i][j] 是第 i 位客户在第 j 家银行托管的资产数量。返回最富有客户所拥有的 资产总量 。
客户的 资产总量 就是他们在各家银行托管的资产数量之和。最富有客户就是 资产总量 最大的客户。
示例 1:
输入:accounts = [[1,2,3],[3,2,1]]
输出:6
解释:
第 1 位客户的资产总量 = 1 + 2 + 3 = 6
第 2 位客户的资产总量 = 3 + 2 + 1 = 6
两位客户都是最富有的,资产总量都是 6 ,所以返回 6 。
示例 2:
输入:accounts = [[1,5],[7,3],[3,5]]
输出:10
解释:
第 1 位客户的资产总量 = 6
第 2 位客户的资产总量 = 10
第 3 位客户的资产总量 = 8
第 2 位客户是最富有的,资产总量是 10
示例 3:
输入:accounts = [[2,8,7],[7,1,3],[1,9,5]]
输出:17
下边附上我的代码
public class Solution {
public int MaximumWealth(int[][] accounts) {
int min = -1;
int row = accounts.GetLength(0);
int[] sum = new int[row];
for(int i=0;i<row;i++)
{
for(int j=0;j<accounts[i].Length;j++)
{
sum[i] += accounts[i][j];
}
}
for(int i=0;i<row;i++)
{
if(sum[i]>min)
{
min = sum[i];
}
}
return min;
}
}
边栏推荐
猜你喜欢
Don't just learn Oracle and MySQL!
自由小兵儿
[mathematical modeling of graduate students in Jiangxi Province in 2022] analysis and code implementation of haze removal by nucleation of water vapor supersaturation
力扣刷题日记/day1/2022.6.23
ThreadLocal原理与使用
神经网络物联网应用技术就业前景【欢迎补充】
[uniapp] uniapp development app online Preview PDF file
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
Digital "new" operation and maintenance of energy industry
Scala基础教程--18--集合(二)
随机推荐
《看完就懂系列》字符串截取方法substr() 、 slice() 和 substring()之间的区别和用法
Deleting nodes in binary search tree
2022健康展,北京健博会,中国健康展,大健康展11月13日
[go ~ 0 to 1] read, write and create files on the sixth day
问下各位大佬有用过cdc直接mysql to clickhouse的么
Using SSH
神经网络物联网平台搭建(物联网平台搭建实战教程)
力扣刷题日记/day2/2022.6.24
中国农科院基因组所汪鸿儒课题组诚邀加入
Scala basic tutorial -- 12 -- Reading and writing data
Journal des problèmes de brosse à boutons de force / day6 / 6.28
Scala basic tutorial -- 18 -- set (2)
Go microservice (II) - detailed introduction to protobuf
一、C语言入门基础
Basic tutorial of scala -- 16 -- generics
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
学习路之PHP--phpstudy创建项目时“hosts文件不存在或被阻止打开”
力扣刷题日记/day3/2022.6.25
How is the entered query SQL statement executed?
[cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!