LeetCode Problem - Link
Today, I solved the Richest Customer Wealth on LeetCode. A pretty straightforward approach for solving this, we're given a 2-dimensional array, we need to loop over them, and maintain one variable for max_wealth, and another variable inside the first loop to keep track of account wealth. If the counter at the end of every loop is greater than max_wealth - we update our max_wealth counter.
/** * @param {number[][]} accounts * @return {number} */ var maximumWealth = function(accounts) { let max_wealth = 0; accounts.map((account)=>{ let current_wealth = 0; account.map((wealth)=>{ current_wealth+=wealth }) if(current_wealth>max_wealth){ max_wealth=current_wealth } }) return max_wealth };