我有形式的传入间隔流(开始,结束)。(1<=开始<结束<=100000)在任何时候,我都想找到不同间隔的数量。
例如
(10,20) comes first-->No of distinct interval 1.
(50,60) comes next->No of distinct interval 2.
(5,11) comes next.->No of distinct interval 3.
(8,12) comes next.->No of distinct interval 3.(As (5,11) has merged with (10,20) and formed (5,20),so (8,12) completely falls in between (5,20),so it wont be counted).
(55,65) comes next.->No of distinct interval 4.(at this point (55,65) will merge with (50,60)).
如何解决这个问题?就像我们可以做一堆自平衡间隔树的间隔吗?如果是,如何?