Minimum Number of Refueling Stops LeetCode solution in Python

1
class Solution:
2
def minRefuelStops(self, t, F, S):
3
S.append([t, 0])
4
heap, ans = [], 0
5
for p, f in S:
6
while heap and p > F:
7
F -= heapq.heappop(heap)
8
ans += 1
9
if p > F:
10
return -1
11
heapq.heappush(heap, -f)
12
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0