I have a set of intervals on the x-axis and i wish to find out the total number of intervals containing a certain element. I know that the problem can be solved by binary search but am not able to do so. How do I code it up? (the intervals may overlap, otherwise I thought of using union find-disjoint set data structure)
Example :
Intervals :
(1,10)
(2,12)
(4,9)
(3,7)
(5,15)
The above intervals are the intervals on the real line.(inclusive) and suppose I have a vector of points:
v=[2,5,6,7,1,3]
How do I proceed with my binary search approach?