Description
Solutions
Shopping and Billing
🔥 FULLTIME📚RELATED PROBLEMS
In a shop with N
counters, M
people arrive for billing at different times denoted as time[i]
. Each person selects the counter with the shortest queue, based on the number of people already present. If a counter is empty, the person gets immediate billing, otherwise, they join the queue.
For every person, output the time when they finish billing and leave the counter.
Notes
- It takes 1 unit of time for the counter to process a person's bill.
- The counter processes the next person immediately after the current person leaves.
Input/Output
- The first line contains
N
denoting the number of counters. - The second line contains
M
denoting the number of persons. - The third line contains an array
time
, indicating the entry time of the people.
Example 1:
Input: N = 2, M = 4, time = [0, 0, 0, 0]
Output: [1, 1, 2, 2]
Explanation:All four people arrive at the same time (time 0). The first two people will go to the two available counters and finish billing at time 1. The next two people will have to wait until the first two leave, so they start billing at time 1 and finish at time 2.
Constraints:
TO-DO

Related Problems
Testcase
Result
Case 1
input:
output: