Efficient method

how to solve this question without using loop method and reduce time complexity?

Archit u have to use the loop as each number have to be visited for finding it set bit
u can modify up to memoization
like
eg
3
1 100
2 99
3 98
these are 3 cases and u can find for the number which u r facing first time and memoize its result and if u get the memoize number again then u can display the result directly like in above eg

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.