Problem
You want to schedule a certain number of trips with a collection of several cabs.
Given an integer n representing a desired number of trips, and an array cabTravelTime representing your cabs and how long it takes each cab (at that index of the array) to make a trip, return the minimum time required to make n trips.
Assume that cabs can run simultaneously and there is no waiting period between trips. There may be multiple cabs with the same time cost.
Examples
If n=3 and cabTravelTime=[1,2], then the answer is 2. This is because the first cab (index 0, cost 1) can make 2 trips costing a total of 2 time units, and the second cab can make a single trip costing 2 at the same time.
n=10
cabTravelTime=[1,3,5,7,8]
n=3
cabTravelTime=[3,4,8]
Solution (?)
My intuition was:
cabTravelTime arrayThis passed the some test cases but failed a bunch of others, including hidden test cases which hit the time limit. I think it's okay for the test cases I provided here but I don't remember them all. I'm unsure if my intuition or implementation was wrong, or both.