행 : 고객
열 : 은행
고객이 보유하고있는 각 은행 별 계좌중
가장많은 돈을 보유하고 있는 고객의 계좌의 총 합을 반환한다.
class Solution {
public int maximumWealth(int[][] accounts) {
int tempAccountSum = 0;
int richAccountSum = 0;
for(int i = 0; i < accounts.length; i++){
tempAccountSum = 0; // 임시 값 초기화
for(int j = 0; j < accounts[i].length; j++){
tempAccountSum += accounts[i][j]; //배열 총합
}
if(richAccountSum > tempAccountSum) { // 임시보다 결과값이 크면 무시
continue;
}
richAccountSum = tempAccountSum;
}
return richAccountSum;
}
}