I have a use case where if a number lies between 0-10 it should return 0 and if it lies between 11-20 it should return 1 etc
0 => 0-3, (0 and 3 are inclusive)
1 => 4-15, (4 and 15 are inclusive)
2 => 16-40, (16 and 40 are inclusive)
3 => 41-88, (41 and 88 are inclusive)
5 => 89-300 (89 and 300 are inclusive)
I was thinking how could I implement and was thinking java maps, but it does not allow range searching
I am interested in something like this , I have a function
int foo() {
}
if foo returns 5 , since it lies between 0 to 10 I would use 0, if foo return 25 it would use 2.
Any ideas
Edit : Actually the ranges are not as simple as 0-10, 11-20. I want to be able to do range searches. Sorry about the confusion. Based on the queries I have added the correct example, the numbers are continous