Very very simple c ++ solution, but it takes a long time


  • 0

    Forgive me,I am a novice............

    class Solution {
    public:
        int mySqrt(int x) {
            long i=0;
            while(i*i<=long(x))
            {
                i+=1;
                
            }
            return i-1;
        }
    };

Log in to reply
 

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