code.ashish.me

Atom feed

Recently added: 02 Count Of Subset Sum, 416 Partition Equal Subset Sum, 01 Subset Sum, 518 Coin Change 2, 983 Minimum Cost For Tickets

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-31T09:51:49+05:18 · Edit