I have encountered this question recently in non-FANG company. Given 25 minutes to implement. I failed :) Given the fact I have solved 400+lc
Customers at a department store make their purchases from 3 cashiers. All the customers wait their turn in one line. As soon as a cashier becomes available, the person at the head of the line goes to that cashier. Customers do not arrive all at once, but at a time recorded as the number of minutes since the store opened.
Implement a function storeEmptyAt([int minutesSinceOpen, int durationInMinutes][] customerArrivals) that computes the time at which all the customers have completed their purchases. You may assume customerArrivals is ordered by arrival time. And if multiple customers arrive simultaneously, queue them in the same order as given by customerArrivals.
Example:
storeEmptyAt([[0,7], [1,3], [1,4]]) // 7 minutes
Test cases
storeEmptyAt([[0,2], [0,5], [1,3], [2,2]]) // 5 minutes
storeEmptyAt([]) // 0 minutes
storeEmptyAt([[0,2], [1,2], [2,3]] ) // 5 minutes
storeEmptyAt([[0,2], [0,3], [0,1], [0,4], [0,3], [0,3], [1,2], [2,3], [2,2], [2,5], [2,3], [2,6], [2,5], [3,4], [4,3], [4,1], [4,2], [4,3], [5,5], [7,3]]) // 22 minutes
storeEmptyAt([[0,2], [0,1], [0,2], [3,3], [3,1], [3,2], [3,3]]) // 7 minutes
storeEmptyAt([[0,1], [0,2], [0,3], [0,4], [0,5], [0,6], [0,7], [0,8], [0,9]]) // 18 minutes
storeEmptyAt([[0,3], [0,1], [0,3], [0,2], [11,3], [11,1], [11,2], [11,3]]) // 15 minutes