当前位置:网站首页>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;
}
}
边栏推荐
- Cache é JSON uses JSON adapters
- How to modify icons in VBS or VBE
- Scala basic tutorial -- 14 -- implicit conversion
- [release] a tool for testing WebService and database connection - dbtest v1.0
- 利用策略模式优化if代码【策略模式】
- Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
- 力扣刷题日记/day5/2022.6.27
- Lex and yacc based lexical analyzer + parser
- Li Kou brush question diary /day5/2022.6.27
- Rookie post station management system based on C language
猜你喜欢
随机推荐
What types of Thawte wildcard SSL certificates provide
Scala基础教程--17--集合
Principle and application of ThreadLocal
神经网络物联网是什么意思通俗的解释
Scala基础教程--18--集合(二)
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
李迟2022年6月工作生活总结
力扣刷题日记/day6/6.28
英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
Scala基础教程--12--读写数据
Scala基础教程--19--Actor
工厂从自动化到数字孪生,图扑能干什么?
sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
神经网络物联网应用技术学什么
正则替换【JS,正则表达式】
Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
Wireshark packet capturing TLS protocol bar displays version inconsistency
启牛开的证券账户安全吗?
Scala基础教程--20--Akka
How is the entered query SQL statement executed?