最富有的客户财富

ID:17160 / 打印

最富有的客户财富

问题

https://leetcode.com/problems/richest-customer-wealth/description/

解决方案

 class solution { public int maximumwealth (int[][] accounts) { int wealth  = 0;         for (int[] customer : accounts) {               int currentcustomerwealth = 0;     for (int bank : customer) {               currentcustomerwealth += bank;     }            wealth  = math.max(wealth , currentcustomerwealth); }            return wealth ; } } 

解决方案02

 class Solution {     public int maximumWealth(int[][] accounts) {         int wealth = 0;         // Loop through each customer         for (int i = 0; i < accounts.length; i++) {             int currentCustomerWealth = 0;             // Loop through each bank account for the current customer             for (int j = 0; j < accounts[i].length; j++) {                 currentCustomerWealth += accounts[i][j]; // Add the bank balance to current customer's wealth             }             // Update maximum wealth if current is greater             wealth = Math.max(wealth, currentCustomerWealth);         }         return wealth; // Return the maximum wealth found     } } 
上一篇: Java Stream 泛型不填会带来什么问题?
下一篇: Java Stream泛型不填写为何会导致类型擦除问题?

作者:admin @ 24资源网   2024-11-27

本站所有软件、源码、文章均有网友提供,如有侵权联系308410122@qq.com

与本文相关文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。