leetCode 문제풀이 1672번 Richest Customer Wealth (JS)

devmomo·2021년 3월 10일
0

알고리즘

목록 보기
11/52
post-thumbnail

1672. Richest Customer Wealth

문제
accounts라는 2차원의 배열이 매개변수로 주어졌을 때, 배열을 순회하며 최댓값을 리턴
풀이

var maximumWealth = function(accounts) {
    const result = accounts.map((data)=>
       data.reduce((acc,curr)=>acc+curr));
    return Math.max(...result);
};
profile
FE engineer

0개의 댓글