Count of set bits at an index in a given range

73 views Asked by At

I could not find any such query. Given a range and the index i, we want to count the numbers in the range that have bit i set.

Eg, range=[6,13] and i=2, ans=4

6 0110

7 0111

8 1000

9 1001

10 1010

11 1011

12 1100

13 1101

Is there a better approach than traversing the range

0

There are 0 answers