Minimum Time to Complete Trips
You are given an array time where time[i] denotes the time taken by the i^th bus to complete one trip.
Each bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, the trips of one bus do not influence the trips of any other bus.
You are also given an integer totalTrips, which denotes the number of trips all buses should make in total. Return the minimum time required for all buses to complete at least totalTrips trips.
Example 1
Input
time = [1,2,3], totalTrips = 5Output
3At time
t = 3, the buses complete [3, 1, 1] trips for a total of 5 trips, so 3 is the minimum time needed.Example 2
Input
time = [2], totalTrips = 1Output
2There is only one bus, and it completes its first trip at
t = 2, so the minimum time needed is 2.Constraints
- 1 <= time.length <= 10^5
- 1 <= time[i], totalTrips <= 10^7