Design a data structure that supports weighted random pop

This is similar to https://leetcode.com/problems/random-pick-with-weight/, but we're not just picking an index here, we need to also pop it from the data structure. We also have to implement a push operation. Both of these operations have complexity better than O(n) time.

It seems a segment tree or BIT would work here?

Comments (0)