개발 노트/LeetCode 풀이
[JS] 1672. Richest Customer Wealth
tokkiC
2022. 11. 16. 00:27
이차원 배열의 연산 문제
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);
};