@xinyufeng16 said in Easy JAVA solution beat 98%:

@vegito2002

In your LEMMA 1:

"WLOG we suppose m > n, and we know that there are m intervals that starts before interval i starts, and there are n intervals that ends before interval i ends, and immediately we know that there are m - n intervals that starts earlier than interval i, but ends later than interval i."

m includes intervals that starts before interval i starts, but not includes intervals that starts after interval i starts and before i ends. And since there are n intervals that ends before interval i ends, so, n might include some intervals that start later than i.

Suppose [1,2] [3,4],[5,6] [7,100] [8,99] [9 98]

Start: 1,2,3,5,6,7,8,9

End: 2,4,6,98,99,100

So, suppose m = 8, n = 3, m > n, and m - n = 5, but there are less 5 intervals that ends later than [9 98]

Thus, how can you interpret this: "immediately we know that there are m - n intervals that starts earlier than interval i, but ends later than interval I"

Hi, thanks for the reply, but I think you statement is not well-formated. In your example, you have 6 intervals, but you have 8 starts and 6 ends after sorting. Also, when you say m=8, it seems that you interprets m as 1-based, but when you say n=3, it looks like you are using 0-based again. It does not really matter whether you use 0-based or 1-based, but you have to pick one and apply it consistently to m and n. Can you please rephrase your opinion, exp. your example? It is kinda confusing to me now what your objection is.

If for [1,2] [3,4],[5,6] [7,100] [8,99] [9 98], we actually have:

starts
ends
1
2
3
4
5
6
7
98
8
99
9
100

And [9,98], if 0-based, then we have m=5, n = 3, and m-n=2, meaning there are 2 intervals that starts before [9,98] and ends later than it: they are [7,100] and [8,99]. I don't see the problem here.