Heim >Java >javaLernprogramm >Reichstes Kundenvermögen
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 ; } }
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 } }
Das obige ist der detaillierte Inhalt vonReichstes Kundenvermögen. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!