All problems
0482EasyArrayMatrix

Depot Holding the Most Stock

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1672Richest Customer Wealth

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

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 is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

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