Daily challenge for 2026-08-22
599. Fuel Efficient Delivery Route
You are given an array of integers stations representing the locations of fuel stations along a straight highway, and an integer capacity representing the maximum distance your vehicle can travel on a full tank of fuel. You start at location 0 with a full tank of fuel. You want to reach the last station in the list. Determine the minimum number of refueling stops required to reach the destination. If it is impossible to reach the destination, return -1.
Assume you only refuel when necessary (greedy approach), and you can always refuel to full capacity at any station.
Example:
Input: stations = [3, 6, 7, 10], capacity = 4
Output: 2
Explanation: Start at 0 with 4 fuel. Stop 1: Go to station 3 (remaining fuel 1, refuel to 4). Stop 2: Go to station 6 or 7. To minimize stops, go to 7 (remaining fuel 0, refuel to 4). From 7, go to 10 (remaining fuel 1). Total stops: 2.