Need Help in a question

Given Q queries, with each query consisting of two integers L and R, the task is to find the total numbers between L and R (Both inclusive), having atmost two set bits in their binary representation.

Q<=10^5
L,R<=10^18

Question link: https://practice.geeksforgeeks.org/problems/the-range-query/0

Hi,

This can be solved using Pre-computation(which will generate numbers with at-most 2 set bits in binary representation and then using binary search on the generated numbers.

As the numbers are in the range of 10^18 , there can be at-most 60 bits in its binary representation.
So use 2 loops (i,j) for simulating those values and then insert the generated number in a set (which maintains the sorting order) and then use binary search on the given ranges to find the answer which will surely fit within the time limit .

Thank you, got it. I should spend more time before asking.