• + 0 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.