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.
always jumped to the most distante city within k, and checked backwards if there was a possible power plant, if checking reached index 0 or the currentIndex reached back the last possible plant without findind another possible plant return -1
whenever finding a plant jump to the next maximun possible city within 2 power plants reach (the recently found and a possible one at 2 * k - 1, beacuse k has to account for the powerplant city itself) of distance, so no unnecessary power plant is counted.
the lookup stops if the last city found is close enough to the last one
Goodland Electricity
You are viewing a single comment's thread. Return to all comments →
Javascript resolution
always jumped to the most distante city within k, and checked backwards if there was a possible power plant, if checking reached index 0 or the currentIndex reached back the last possible plant without findind another possible plant return -1
whenever finding a plant jump to the next maximun possible city within 2 power plants reach (the recently found and a possible one at 2 * k - 1, beacuse k has to account for the powerplant city itself) of distance, so no unnecessary power plant is counted.
the lookup stops if the last city found is close enough to the last one