[algogeeks] Re: Google Interview Question: In how many intervals does a number exists

2013-06-10 Thread sunny
yeah interval tree and binary indexed tree is a one solution which will give you answer in log(n) time for each query ,but if i got all the interval at the beigning of time i can get solution in O(1) time by O(n ) preprocessing take array f initialize with zero,now for each interval(l,r) do

[algogeeks] Re: Google Interview Question: In how many intervals does a number exists

2013-06-10 Thread sunny
typo mistake take prefix sum of f and see each index value...continue On Sunday, June 9, 2013 12:50:46 PM UTC+5:30, Monish Gupta wrote: There are n Intervals. Given a set of m numbers, tell in how many intervals does each number exists. Example: 4 Intervals: [2,3] [3,4] [1,4] [3,10]. Numbers