You are viewing a single comment's thread. Return to all comments →
Can anyone explain the logic behind this program. Thanks.
as you move through the list, you sum up the Diff = (fuel-distance). If this value ever drops below 0 then it means you can't start from any point up to this point and still make it past this point. You therefore set the next possible point as the pump after your current one and try again.
" you can't start from any point up to this point and still make it past this point "
how did you fifure out that one
suppose you start from 1, 2, 3, and breaks at 4, removing 1 from the route (starting from 2) only decrease the petro you collect and surely breaks again.
This was what i wanted to know!!!
Me, as well!!!