I was thinking to use HashMap but I think either I have to customize it or I have to create custom data structure for it. As we know HashMap stores Key-Value pair but I need a data-structure where instead of a single key I should be able to put a range. For example:
Range Should return
0 to 50 Object1
51 to 100 Object2
90 to 150 Object3
So if user search for 10. He should be able to get Object1, if user search for 55. He should be able to get Object2, if user search for 95. He should be able to get Object2 and Object3 both.
I was thinking to put range inside each object and putting all the objects into an ArrayList or LinkedList and then I can iterate it and find the all Objects which are satisfying the input. But its time complexity will be more. For every input I have to traverse whole list. I thought for tree also but in case of overlapping range (like 51 to 100 and 90 to 150), I could not figure out how that will be helpful.
Let me know your views, my target is time complexity should be less like or near to hashmap