The code accepted but a trick?


  • 0
    M
    class Solution {
    public:
        int sqrt(int x) {
            if(x<=0)return 0;
            if(x==1)return 1;
            int st1=x/2<46340?x/2:46340;
            int nd2=st1;
            while(st1*st1>x)
            {
                nd2=st1;
                st1=st1/2;
            }
            while(nd2>st1&&nd2*nd2>x)
            {
                nd2--;
            }
            return nd2;
        }
    };

Log in to reply
 

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