Remove Interval

3

4 votes
, Algorithms, Binary Search
Problem

Given N intervals of the form [L,R] .

Removal cost of an interval is defined as the number of intervals with which it overlaps other than itself.

Among the removal cost of all given intervals, find the minimum possible removal cost.

Input Format:

  • First line contain N, denoting the number of intervals
  • Next N lines contain two integers L  R , denoting the interval.

Output Format:
Print an integer corresponding to minimum removal cost among N intervals.

Constraints

1N1051LR105

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Removal cost for interval 1 is 1 because it overlap with only interval 2

Editor Image

?