Problem description
Joseph is standing at k+1th position in a queue at an insurance company's office and there are n counters at the office, ith counter takes time[i] time (minutes) to process a request. The security guard assigns a counter to the person standing in the front of the queue as soon as a counter is available or if multiple counters are available, then the security official assigns the counter with minimum id (consider id as index). What would be the time at which Joseph's request would be processed aka the ending time when Joseph leaves the office?
Example case
n = 3
times = [3,2,5]
k = 4
Person 1: assign counter 0 (available counter with minimum index)
Person 2: assign counter 1 (available counter with minimum index)
Person 3: assign counter 2 (available counter with minimum index)
Person 4: assign counter 1 (available counter with minimum index)
Person 5 (Joesph): assign counter 0 (available counter with minimum index)Solution proposed
n counters to the queue with ending time as 0k positions:
endTime + time taken to process request for that counterInterview Experience Post: https://leetcode.com/discuss/interview-question/2199510/Google-or-L4-or-India-or-June-2022-or-Accepted