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.
time = [1,2,3], totalTrips = 53t = 3, the buses complete [3, 1, 1] trips for a total of 5 trips, so 3 is the minimum time needed.time = [2], totalTrips = 12t = 2, so the minimum time needed is 2.Constraints
- 1 <= time.length <= 10^5
- 1 <= time[i], totalTrips <= 10^7
Asked at 5 companies
Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.