code.ashish.me

Atom feed

Recently added: 128 Longest Consecutive Sequence, 347 Top K Frequent Elements, 045 Jump Game 2, 228 Summary Ranges, 219 Contains Duplicate 2

1672 Richest Customer Wealth

/**
 *
 * Ashish Patel
 * e: ashishsushilPatel@gmail.com
 * w: https://ashish.me
 *
 */

function TreeNode(val) {
  this.val = val
  this.left = this.right = null
}

const richestCustomerWealth = accounts => {
  return accounts.map(a => a.reduce((a, t) => (t += a), 0)).sort((b, a) => a - b)[0]
}

test('richestCustomerWealth', () => {
  expect(
    richestCustomerWealth([
      [1, 5],
      [7, 3],
      [3, 5],
    ]),
  ).toEqual(10)
})

Created 2021-01-31T10:03:49+05:30 · Edit