Problem 139210 · medium · Phase 01 Prerequisites & Setup

Shortest Checkout Lane

nested loops · lists · conditionals

A supermarket has k checkout lanes, all empty at first. Customers arrive one at a time; customers lists how many items each one carries. Each customer joins the lane whose current total number of items is smallest; if several lanes tie, they pick the one with the lowest index. Their items are then added to that lane. Return the final item totals of all lanes.

Examples

Input:  k = 2, customers = [5, 3, 4, 1]
Output: [6, 7]
Explanation: 5->lane 0, 3->lane 1, 4->lane 1 (3 < 5), 1->lane 0 (5 < 7).

Input:  k = 3, customers = [2, 2]
Output: [2, 2, 0]

Constraints

  • 1 <= k <= 20, 0 <= len(customers) <= 1000, 1 <= items <= 100

Goals

  • Find the index of the minimum value in a list (first one on ties)
  • Update simulation state after each decision
Starting Python…