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.
- Prepare
- Data Structures
- Queues
- Truck Tour
- Discussions
Truck Tour
Truck Tour
Sort by
recency
|
349 Discussions
|
Please Login in order to post a comment
I'm suprised that the Python brute force approach passed all test cases
def truckTour(petrolpumps):
It looks like this task has error in accepted answer. Truck can start from pump P and go clockwise and counter-clockwise (0->1->2 VS 2->1->0), both way completing the circle from starting point P. The accepted answers considers only clockwise movement. and it's wrong.
Example circle for which backward movement gives result index 0: [10,25;10,1;10,1]
Javascript O(n^2)
O(n)