I dont understand how to solve this using D&C, pls explain.
SIMPLE ENOUGH (D&C)
In this problem, we try to apply the DnC approach on the range from 0 to the maximum depth we can go from N
i.e.
int size(N)
{
if(n==0 or n==1) return 1;
return size(N/2)*2+1;
}
divide the range into two halves, and check for the answer into both halves.
You can refer to this code.