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.
I'm suprised that the Python brute force approach passed all test cases
def truckTour(petrolpumps):
for i, p in enumerate(petrolpumps):
check = p[0] - p[1]
if check >=0:
for i2, p2 in enumerate(petrolpumps[i+1:]):
check += (p2[0] - p2[1])
if check < 0:
break
if check >=0:
return i
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 →
I'm suprised that the Python brute force approach passed all test cases
def truckTour(petrolpumps):