Simple C++ Solution


  • 0
    I

    class Solution {
    public:

    int mySqrt(int x) {
        if (x < 1)
        {
            return 0;
        }
        
        int answer = 1;
                
        while (answer <= x / answer)
        {
            answer++;
        }
        
        return answer - 1;
    }
    

    };


Log in to reply
 

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