Show problems as
Classic problem #1672EasyArrayMatrix

Richest Customer Wealth

Real-world version: Depot Holding the Most Stock
Tracked in this browser only
Read Richest Customer Wealth on LeetCode(opens in a new tab)

The statement here is our own: the same inputs, outputs and technique.

A wholesaler runs several depots and carries the same set of product lines in each of them. stock[d][p] is the number of units of product line p sitting in depot d.

A depot's holding is the number of units it has across all of its product lines added together.

Return the largest holding of any single depot.

Examples

Example 1

Input
stock = [[7, 2, 9], [4, 4, 4], [1, 1, 20]]
Output
22

Depot 0 holds 18 units, depot 1 holds 12 and depot 2 holds 22, so the largest holding is depot 2's.

Example 2

Input
stock = [[100, 1], [50, 49]]
Output
101

Depot 0 holds 101 units and depot 1 holds 99.

Example 3

Input
stock = [[6, 4], [5, 5]]
Output
10

Both depots hold ten units in total, so that figure is what comes back.

Constraints

  • m == stock.length
  • n == stock[d].length
  • 1 <= m, n <= 50
  • 1 <= stock[d][p] <= 100

The signature

The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.

Python
def busiest_depot_total(stock: list[list[int]]) -> int:
Java
public int busiestDepotTotal(int[][] stock)