Z41

Minimum Refueling Stops

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

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]]) -> int

Input & 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^9

Example 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 ikmal

Example Test Scenarios (3)

Example 1
Input:[100,10,[[10,60],[20,30],[30,30],[60,40]]]
Expected Output:2
Example 2: Zaten Ulaşır
Input:[1,1,[]]
Expected Output:0
Example 3: İlk İstasyona Ulaşamaz
Input:[100,1,[[10,100]]]
Expected Output:-1
Loading Python Editor...
Input Parameters
[
  100,
  10,
  [
    [
      10,
      60
    ],
    [
      20,
      30
    ],
    [
      30,
      30
    ],
    [
      60,
      40
    ]
  ]
]
Expected Output
2