1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
long long int floorSqrt(long long int x) { // Your code goes here int lo=0,hi=1000,mid; while(hi-lo>=1) { mid=(lo+hi)/2; if(mid*mid<x) lo=mid+1; else if(mid*mid>x) hi=mid-1; else return mid; } if(lo*lo>x) return lo-1; else return lo; } |