We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The below code if(sum>0) pass all tests.
But if(sum>=0) fails, why?
I think the truck should consider to reach the station when the gas down to 0
inttruckTour(vector<vector<int>>petrolpumps){intsum;intstartPoint=0;intlen=(int)petrolpumps.size();while(startPoint<len){sum=0;for(inti=0;i<len;++i){intii=(startPoint+i)%len;//circlesum+=petrolpumps[ii][0]-petrolpumps[ii][1];if(sum<0){++startPoint;break;}}if(sum>0)// I think `if(sum>=0)` is ok, but test cases fail{returnstartPoint;}}return-1;}
Truck Tour
You are viewing a single comment's thread. Return to all comments →
The below code
if(sum>0)
pass all tests. Butif(sum>=0)
fails, why? I think the truck should consider to reach the station when the gas down to 0