Description: Please writeProgramFind the maximum overlap interval in the input data file described in "input data and format" below.
For a positive integer N, if n is between two positive integers (assume a and B) in a row in the data file, that is, if a <= n <= B or a> = n> = B, n belongs to the row. If n belongs to both I and J, there is an overlap between I and j; the size of the overlap interval is the number of integers belonging to both row I and J.
For example, the overlapping ranges of rows (10 20) and (12 25) are [12 20], the size is 9, rows (20 10) and (20 30) the size of the overlap interval is 1.
Ideas:
Use N * log (n) First, sort the order by the Left endpoint of the interval (the smaller number), and then traverse it with O (n!
The traversal process only records the maximum value of the right endpoint (the larger number), the overlap interval = the maximum value-the current left endpoint value, and the maximum overlap interval generated is recorded!
You can also use the line segment tree, but it is the same!