How would we implement a multiset data structure that allows insertion, deletion and querying GCD of values currently present in multiset?
insert(5)
GCD() -> 5
insert(10)
GCD() -> 5
remove(5)
GCD() -> 10
This question is not from some existing problem and was just wondering if it was possible to have such data structure where deletion is possible on operations like GCD. I believe this would be helpful https://cp-algorithms.com/data_structures/deleting_in_log_n.html but can't understand how we would apply this or maybe some other method which would work for large numbers upto 1e18.