Pick the points on horizontal axis

Viewed 46

There are many sets of points on the horizontal axis of coordinate plane. If a point is plotted in between any set that set is reduced to that point. Given X Sets, find minimum number of points one should pick to reduce all points to minimum number of points.

Input specification :

input 1 ; X number of Sets
input 2 : array consisting of X pairs,each pair indicating start and end of set

Output specification: return integer as per question.

Example 1 :

input 1 : 3
input 2 : [{1 ,3}, {2, 5}, {3, 6}]

Output : 1

enter image description here

Example 2 :

input 1 : 3
input 2 : [{1 ,3}, {2, 5}, {6, 9}]

Output : 2

Can any one please help me with this ds algo question, I've faced this in an interview and trying to understand the problem but couldn't get it.

0 Answers
Related