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.
The editorial is reasonably useful, but it's possible to find k in O(1) time (with O(max N) preprocessing, as in the editorial), giving an overall time of O(T + N) using a bit more math. The pattern isn't too hard to see, once you look for it.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Random Number Generator
You are viewing a single comment's thread. Return to all comments →
The editorial is reasonably useful, but it's possible to find k in O(1) time (with O(max N) preprocessing, as in the editorial), giving an overall time of O(T + N) using a bit more math. The pattern isn't too hard to see, once you look for it.