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.
It seems that C++ is fast enough for an O(Q(N+1000)) solution. Since the number of books is limited to 1000, counting sort is applicable. If the queried range was close to N each time, it would probably not pass the time limit (worst case ~10^8 operations), but it does pass for the given test cases.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Library Query
You are viewing a single comment's thread. Return to all comments →
It seems that C++ is fast enough for an O(Q(N+1000)) solution. Since the number of books is limited to 1000, counting sort is applicable. If the queried range was close to N each time, it would probably not pass the time limit (worst case ~10^8 operations), but it does pass for the given test cases.