Fast Algorithm to Quickly Find the Range a Number Belongs to in a Set of Ranges?

后端 未结 5 1611
情书的邮戳
情书的邮戳 2020-11-29 00:53

The Scenario

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

5条回答
  •  暖寄归人
    2020-11-29 01:31

    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.

提交回复
热议问题