LeetCode solutions

2294. Minimum Time to Complete Trips

My accepted Python solution to LeetCode problem 2294, Minimum Time to Complete Trips, running in 599ms.

  • Difficulty: Medium
  • Python
  • Runtime 599ms
  • Memory 29.9MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 599ms, memory 29.9MB, accepted 2025-12-29.

python
class Solution:
    def minimumTime(self, time: List[int], totalTrips: int) -> int:
        def canComplete(t):
            trips = 0
            for bus_time in time:
                trips += t // bus_time
            return trips >= totalTrips
        
        left = 1
        right = min(time) * totalTrips
        
        while left < right:
            mid = (left + right) // 2
            if canComplete(mid):
                right = mid
            else:
                left = mid + 1
        
        return left

Source