#1250Hard· asked at 3 companies
Minimum Number of Refueling Stops
Hosted on LeetCode
Solve it on LeetCode, track it here.
This problem's full statement lives on LeetCode. Open it in a new tab, then come back to mark it solved, add notes and keep your streak.
LeetCode Premium locked?
Most company-tagged LeetCode problems are behind Premium. If you have ChatGPT Plus or Claude Pro, ask it for the full statement, examples and constraints. The buttons below open a chat with the prompt already filled in.
What we know
Example 1
Input: target = 1, startFuel = 1, stations = [] Output: 0
Example 2
Input: target = 100, startFuel = 1, stations = [[10,100]] Output: -1
Example 3
Input: target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]] Output: 2
Refuel at station 0 (60) and station 3 (40).
Constraints
- •
1 <= target, startFuel <= 10^9 - •
0 <= stations.length <= 500 - •
1 <= position_i < position_{i+1} < target - •
1 <= fuel_i < 10^9