Find indices of ranges where a number lies.
ranges = {3 , 9} , {2 , 8} , {5 , 10}
f(3) should return { 0 , 1}
f(9) should return {0 , 2}
Bummed out because I was only able to give O(n*maxRange) approach.
O(n * maxRange) for building the ArrayList[] array during the initialization and doing each query in O(1) time
maxRange being the maximum value of right - left in a range {left , right}
After the interview was able to figure out it would probably be solved by Segment Tree, which I did not study :(
I think I'll be rejected.