what will be the efficient approach for this question
Efficient approach
Log(n) per query.
We have to find set bit between a and b.
So we find set bit between 1 to b then 1 to a in log(n) then find the difference.
Here is a trick to find count of first n set bits in logn. Google this query and you will find the trick algorithm.