please see into the code .
Doubt regarding my solution
inside solve function you have to make 3 case
base case if(n==0||n==1)return n%2;
/// no overlap
if(r<s || l >e || s>e)return 0;
in rest case you have to calculate leftans,rightans and also check whether mid lies inside given rang of not if yes then increase ans;
in your code you have use
if(log2(a)==ceil(log2(a)))
{x=ceil(log2(a))+1;}
else x=ceil(log2(a));
to find end index this is not working i have tried this
may be this is not applicable for all
so instead of this you can use a simple function see in the code
you can take help from this code
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.