69. Sqrt(x)
Last updated
Last updated
/**
*
*
*/
class Solution {
public int mySqrt(int x) {
if(x == Integer.MAX_VALUE) x--;
int p = x, q = 1;
while(p-q > 0.1) {
p = (p + q)/2;
q = x/p;
}
return (int)p;
}
}