I have several number ranges. Those ranges are not overlapping - as they are not overlapping, the logical consequence is that no number can be part of
A balanced, sorted tree with ranges on each node seems to be the answer. I can't prove it's optimal, but if I were you I wouldn't look any further.