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.
There is a solution with complexity O(N*log(K)) and O(K) space that would be much better if N >> K. Since the question has a very limited N, and K can be anything up to N, it probably doesn't matter but I thought it was worth mentioning :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Luck Balance
You are viewing a single comment's thread. Return to all comments →
There is a solution with complexity O(N*log(K)) and O(K) space that would be much better if N >> K. Since the question has a very limited N, and K can be anything up to N, it probably doesn't matter but I thought it was worth mentioning :)