### Segment Tree question

Posted:

**Wed Oct 08, 2014 7:55 am**Hello, I recently remembered a problem statement that was something like this :

We have an array A of n integers and we need to answer the following type of queries. Q(l, r, p) means how many numbers from A[l..r] are less than p. The author mentioned that it can be done using a segment tree, but did not provide any further clarifications and I cannot wrap my head around it.

Any ideas/tips ?

Thanks in advance !

We have an array A of n integers and we need to answer the following type of queries. Q(l, r, p) means how many numbers from A[l..r] are less than p. The author mentioned that it can be done using a segment tree, but did not provide any further clarifications and I cannot wrap my head around it.

Any ideas/tips ?

Thanks in advance !