Leetcode 2294 Solution
This article provides solution to leetcode question 2294 (minimum-time-to-complete-trips)
Access this page by simply typing in "lcs 2294" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/minimum-time-to-complete-trips
Solution
class Solution:
def minimumTime(self, time: List[int], totalTrips: int) -> int:
def check(totalTime):
nonlocal time
nonlocal totalTrips
return sum([totalTime // bus_time for bus_time in time]) >= totalTrips
l = 0
r = sum(time) * totalTrips
while l < r:
m = (l + r) // 2
if check(m):
r = m
else:
l = m + 1
return l