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.
petrolRest = [pump[0]-pump[1] for pump in petrolpumps] * 2
for i in range(len(petrolpumps)):
tank = 0
for j in range(i, i + len(petrolpumps)):
tank += petrolRest[j]
if tank < 0: break
if tank < 0: continue
else: return i
return -1
Cookie support is required to access HackerRank
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 →
def truckTour(petrolpumps):