Need help in set.

help
pair
sets

#1

Given a set of pairs. Each pair represent a range of numbers.

Example : (5, 8) represents {5, 6, 7, 8}.

I want to find in which pair an element x is present, it is sure that element x exits in at least one pair?

Can this be solved in logarithmic time? Thanks in advance!


#2

There must be some other constraints too else this would be a very easy problem.Just take min and max value of the set.That would be your answer.


#3

“Can this be solved in logarithmic time?”
This is the constraint I guess.


#4

is there are overlapping pairs?


#5

Sort, join overlapping pairs, binary search.


#6

Can you please paste the exact link of question? It will help us to sort out weather it is genuine question or it is not taken from any ongoing contest.