0ms c++


  • 0
    B
    class Solution
    {
    public:
        int sqr(double n)
        {
            double k=1.0;
            while(fabs(k*k-n)>1e-9)
            {
                k=(k+n/k)/2;
            }
            return trunc(k);
        }
    
        bool isPerfectSquare(int num)
        {
            int tmp=sqr(num);
            if (tmp*tmp==num) return true;else return false;
        }
    };
    

Log in to reply
 

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