69. Sqrt(x)

 class Solution {

public:
    int mySqrt(int x) {
          long r = x;
    while (r*r > x)
        r = (r + x/r) / 2;
    return r;
    }
}

Comments

Popular posts from this blog

1431. Kids With the Greatest Number of Candies

125. Valid Palindrome

771. Jewels and Stones