Given a set of closed intervals, find the smallest set of numbers that covers all the intervals. If there are multiple smallest sets, return any of them
Answers
Answered by
5
Answer:
Sort the given interval based on ending point and mark smallest number as 'x'.
Sort the given interval based on starting point and mark the largest number as 'y'.
Answer is {x,y}
Step-by-step explanation:
For example , interval is {[0,3],[2,6],[3,4],[6,9]}.
After sorting above interval based on ending point, we get :- 3,4,6,9. So x= 3.
After sorting above interval based on starting point, we get :- 0,2,3,6. So y=6.
So answer is {3,6}
Similar questions