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 can be solved with a kind of insertion sort, in a grouped list, where the groups will be responsible for reducing the complexity of the operation, I did it this way with groups of size sqrt(N), so the complexity was in O(sqrt( N)), there may be better ways out there, such as an AVL tree, but as the implementation would be much larger, I preferred to do it that way.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Subsequence Weighting
You are viewing a single comment's thread. Return to all comments →
It can be solved with a kind of insertion sort, in a grouped list, where the groups will be responsible for reducing the complexity of the operation, I did it this way with groups of size sqrt(N), so the complexity was in O(sqrt( N)), there may be better ways out there, such as an AVL tree, but as the implementation would be much larger, I preferred to do it that way.