I'm getting a stream of positive integers to my program. I've to store them as I receive them and be able to answer to range queries that come in between.
A simple solution that came to my mind is to store integers in a hashtable where keys are character representation of the integers(keys must be strings in my hashtable). Then, whenever a range query [a, b] comes, I can simply loop from a to b, check whether key exists and retrieve the value if it does. However, I'm not sure if this is a good approach.
What other alternative solutions exists for this problem?