The answer given in the Understand the problem section is wrong.
Suppose the starting fuel is 14 and the target to be achieved is 59. Which of the following is the correct option for the minimum number of refueling stops?
| Station | Fuel | -------------------------- | 9 | 12 | | 11 | 7 | | 13 | 16 | | 21 | 18 | | 47 | 6 | | 53 | 17 | | 64 | 5 |
The answer is 3 not 4. Stopping at station 9, station 13, and station 21 gives enough fuel to get to the target. The code solution gives an answer of 3.
Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Minimum Number of Refueling Stops - Grokking Coding Interview Patterns in Java