Z41
Minimum Refueling Stops
Problem Statement & Objective
A car travels from a starting position to a target destination. Return the minimum number of refueling stops to reach destination.
Function Signature (Python)
minimum_refueling_stops(target: int, start_fuel: int, stations: list[list[int]]) -> intInput & Output Contract
Output Rule:Minimum ikmal sayısı veya -1.
System Constraints
1 <= hedef, baslangic_yakiti <= 10^9
0 <= istasyonlar.length <= 500
0 < konum < hedef, 1 <= yakit <= 10^9Example Execution Walkthrough
hedef = 100, baslangic_yakiti = 10, istasyonlar = [[10, 60], [20, 30], [30, 30], [60, 40]]
10'da durup 60 al -> 70 yakıt -> 60'a git 40 al -> hedefe var -> 2 ikmalExample Test Scenarios (3)
Example 1
Input:
[100,10,[[10,60],[20,30],[30,30],[60,40]]]Expected Output:
2Example 2: Zaten Ulaşır
Input:
[1,1,[]]Expected Output:
0Example 3: İlk İstasyona Ulaşamaz
Input:
[100,1,[[10,100]]]Expected Output:
-1