This is the solutions for Minimum Avarage Waiting Time challenge.
- Minimize constructed function implemented in MinFunc class
- Optimized solution with PrioQueues
Algorithm has O(N^2) complexity
Let L and M be order time and duration of cooking, ' - denote previous iter vars then Total time passed since start is T = M + max(0, L-T') hence Total waiting time W = W' + M + max(0, T'-L), we want to minimize that
This is one more implementation using PriorityQueues. Despite it has less complexity, pushing to PriorityQueues can have overhead in large number of inputs which might be the case given challenge distribution range for N.