Topic description Narration:
Given a source interval [x, y] and n unordered target range [X1,y1],[x2,y2],... [Xn,y,] infers that the given source range [x, Y] is not within the target range.
For example: Given the source interval [1 6] and the target range [1 2][2 4][4 9] can feel the interval [1 6] in the target range, due to the source interval of the set of [1 9].
Imagine a collection of such a target range now. It is frequently necessary to query whether an interval is in the set. So how to reduce the complex of single query
The degree of impurity. Pretreatment. The preprocessing of the interval can satisfy this demand.
Directly on the method:
First step: Merge the bands first (that is, set the interval merge into a disjoint interval)
The second step: in this process after the interval to find such a source interval, about the search, of course, two can have a very good effect, then the interval can be sorted.
So: 1 Sorts the interval by its starting point.
2 Merge intersection interval
32 points to find the source range.
The code is as follows:
[Algorithm] Interval coincidence inference