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.
Yeah it pretty easy , when taking coding challenges we always tend to think of alternative more clever way than the basic brute force approach , but in most cases that is the raison why we spend more time for and at the end brute force is easy win .
it is nevertheless a not very generalizable problem and thats why in this case, brute force seems a good alternative. There are not inputs whose solutions are: there is no way of making this circle. Thus, when you assess if each pump has the petrol equivalent to the distance to the next pump, it is just about picking the smaller.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Truck Tour
You are viewing a single comment's thread. Return to all comments →
Yeah it pretty easy , when taking coding challenges we always tend to think of alternative more clever way than the basic brute force approach , but in most cases that is the raison why we spend more time for and at the end brute force is easy win .
it is nevertheless a not very generalizable problem and thats why in this case, brute force seems a good alternative. There are not inputs whose solutions are: there is no way of making this circle. Thus, when you assess if each pump has the petrol equivalent to the distance to the next pump, it is just about picking the smaller.