You are viewing a single comment's thread. Return to all comments →
Cpp Solution:
int truckTour(vector<vector<int>> petrolpumps) { int balance,deficit,start=1; for(int i =0;i<petrolpumps.size();i++){ balance += petrolpumps[i][0] - petrolpumps[i][1]; if(balance < 0){ deficit += balance; start = i+1; balance = 0; } } if(balance + deficit >= 0){ return start; } return -1; }
Seems like cookies are disabled on this browser, please enable them to open this website
Truck Tour
You are viewing a single comment's thread. Return to all comments →
Cpp Solution: