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.
deftruckTour(petrol_pumps):start_index=0total_liters=0total_distance=0foriinrange(len(petrol_pumps)):liters,distance=petrol_pumps[i]total_liters+=literstotal_distance+=distance# Arriving to next petrol pumpiftotal_liters-total_distance<0:# Initialize start index before restarting in start indexstart_index=i+1total_liters=0total_distance=0returnstart_index
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Truck Tour
You are viewing a single comment's thread. Return to all comments →