Why its giving wrong


#1

Blockquote
int bs(int low,int high,int a)
{
if(low==high)
return low;
int mid = low+(high-low+1)/2;
if(mid*mid<=a)
return bs(mid,high,a);
else
return bs(low,mid-1,a);
}

int Solution::sqrt(int a) {
int ans=bs(0,2*1e9,a);
return ans;
}