C 3MS beat 40.16%


  • 0
    L
    int mySqrt(int x) {
        
        if(x<0)
        {
            return 0;
        }
        
        long long num=x;
        
        while(num*num>x)
        {
            num=(num+x/num)/2;
        }
        
        return (int)(num+0.5);
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.