Covering: ZCO 2015

How do I solve the Interval Covering Problem from ZCO 2015???

First sort the input sets according to their starting points. Now start considering 2 sets at a time, in the beginning the 1st and 2nd set. There are 3 cases which will come up.
1)the 2nd set is disjoint from the first one. eg. (1,3) & (5, 19)
2) the 2nd set is contained within the first one. eg. (1, 10) & (3, 7)
3) the 2nd set starts within the first set but ends after it.

Think about how you should approach each of these conditions.
HINT: At times you will increment the total points and at times you will change what sets to consider. This problem gets solved linearly.

1 Like

@arpanb8 You got the algorithm? If anybody needs help beyond this they can ask.

TNXX @Organic-Shilling

But @Organic-Shilling isn’t the worst case complexity O(N^2)? How does it get solved linearly? Although, O(N^2) is enough for this problem…

yep…that is a q. that struck me 2…But n2 is enough for this prob…