educative.io

One of the example answers is wrong

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

Hi @Chris_A

I wanted to reach out, and personally thank you for bringing to my attention the mistake in my lesson. Your feedback was extremely helpful, and I appreciate the time and effort you took to bring this to my attention.

Thanks to your input, I have now corrected the error and the lesson is now more accurate and helpful for future learners.

Once again, thank you so much for your valuable feedback. I look forward to any future suggestions or comments you may have.

1 Like

Hello @Chris_A
Just for your information. The changes will be live in a couple of days.