Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use dynamic programming to solve this problem with each state defined by the city index and fuel left.
Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles.