I wolud like to ask how a different greedy logic would work

what is we keep on travelling as far as we can without refueling.
we keep on travelling max distances( greedy not to stop)

@amangupta we keep on travelling to next station till we have enough fuel to move, once we don’t have enough fuel, we greedily take fuel from already visited stations in descending form(that is we first refuel from station with max fuel and so on).

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.