본문 바로가기
개발 노트/LeetCode 풀이

[JS] 1672. Richest Customer Wealth

by tokkiC 2022. 11. 16.

이차원 배열의 연산 문제

map 과 reduce 를 사용해서 풀어보았다

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

 

Richest Customer Wealth - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

/**
 * @param {number[][]} accounts
 * @return {number}
 */
var maximumWealth = function (accounts) {
  const wealths = accounts.map((el) =>
    el.reduce(
      (base,plus) => {
        return (base += plus);
      },
      0)
    );
  return Math.max(...wealths);
};

'개발 노트 > LeetCode 풀이' 카테고리의 다른 글

[JS] 1. Two Sum  (0) 2022.11.22
[JS] 383. Ransom Note  (0) 2022.11.18
[JS] 1342. Number of Steps to Reduce a Number to Zero  (0) 2022.11.18
[JS] 412. Fizz Buzz  (0) 2022.11.16
[JS] 1480. Running Sum of 1d Array  (0) 2022.11.15

댓글