Number of elements less than or equal to current number in a given range .

Правка en3, от atlasworld, 2019-02-12 23:38:33

You , are given an array of n elements and q queries . Both n and q can range upto 10^5 , and 1<=a[i] <= 10^9.

how to find / count all the elements less than a given element in each query .

Example: index 1 based

a[] = {5 , 3 , 2 , 2 , 3 , 1 , 2 , 9 , 10 , 2 } ****

q1 = 5 9 5 ****

ans = 3 { 3 , 1 , 2} ****

q2 = 1 4 2 ****

ans = 2 {2 , 2 }

The problem gives a feel of segment tree , but how to solve it using ST ?

any idea.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский atlasworld 2019-02-12 23:40:21 2
en4 Английский atlasworld 2019-02-12 23:39:29 121
en3 Английский atlasworld 2019-02-12 23:38:33 8
en2 Английский atlasworld 2019-02-12 23:38:13 36
en1 Английский atlasworld 2019-02-12 23:37:52 523 Initial revision (published)