LeetCode - 1672(JS, Easy)

진영·2024년 4월 1일
0

LeetCode

목록 보기
5/16

1672. Richest Customer Wealth

난이도: Easy

문제해설

You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. Return the wealth that the richest customer has.
A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth.

정답

/**
 * @param {number[][]} accounts
 * @return {number}
 */
var maximumWealth = function(accounts) {
    let row = accounts.length;
    let col = accounts[0].length;
    let max = 0;
    for(let i = 0; i < row; i++){
        let temp = 0;
        for(let j = 0; j < col; j++){
            temp += accounts[i][j];
            if(max < temp) max = temp;
        }
    }

    return max;
};
profile
개발하고 만드는걸 좋아합니다

0개의 댓글

관련 채용 정보