I have a collection, I don't know which data structure to use yet for this. I have two functions, add and remove.
Both of the functions need to have similar complexities because they both are as frequently used.
It's either add function will be simple as O(1) and removeMax
will be O(log n) or both o(1) or one of them log n and other o(n).
removeMax
should remove the maximum value and return it, and should be able to use it multiple times, so the next time u call it it removes the next new max value.
Is there a way to do both with O(1) or atleast log n for remove?