You are viewing a single comment's thread. Return to all comments →
public static int truckTour(List<List<int>> petrolpumps) { var cnt = petrolpumps.Count(); var delta = new int[cnt]; for(int i=0; i< cnt; i++) { delta[i] = petrolpumps[i][0] -petrolpumps[i][1]; } for(int i=0; i< cnt; i++) { int sum = 0; bool find = true; for(int j=i; j<cnt+i; j++) { var indexJnew = j%cnt; sum += delta[indexJnew]; if(sum<0) { find = false; break; } } if(find == true) { return i; } } 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 →