I'm looking for a suitable data structure that supports two operations:
- Adding a number to a set.
- Querying the minimum number of 1s in the binary representation of
a given number X xor {a number from the set}.
I have thought about using a segment tree since we have updates and queries but can't figure out how to do that. I also tried to implement a trie solution but it basically had exponential complexity.
I need a structure that supports this minimum query in logarithmic complexity.
Any tips would be appreciated. Thank you! :)