Comment body goes here.

int Solution::sqrt(int A) {

if(A == 0 || A == 1) return A;

if(A == 2 || A == 3) return 1;

int ans=0;

for(long long i=1;i<=A/2;i++)

{

if(i*i<=A)

{

ans=i;

}

else

break;

}

return ans;

}

# How can i optimize it further?

**akansh-mowar**#1

Your solutionâ€™s run time is O(A) but they are expecting O(logA). You can do a binary search from 1 to A to find the answer to this problem.

you need to start from 1 to A and apply Binary search.just replaced condition with square ones.

so time complexity would be O(logA)