N Circular Petrol Pumps | Queue | C++ Solution
N Circular Petrol Pumps, is a Queue related problem and in this post we will see how we can solve this challenge in C++
given 'n' petrol pumps located on the circumference of a circle . given the petrol each of pumps have and the dist from that ptrol pump to the next one find the first starting point such that we cover the entire circle Using queue we store each petrol pump index and traverse.At any point if the the total petrol becomes lesser than the remaining distance, then dequeue the index and mark the next front index as the starting index
Please check the main.cpp snippet for the solution.
This solution originally posted at: Github by @susantabiswas
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.