public class Solution {
/**
* @param x: a double
* @return: the square root of x
*/
public double sqrt(double x) {
double left = 0;
double right = Math.max(x, 1.0);
double delta = 1e-12;
while (left + delta < right) {
double mid = left + (right - left) / 2;
if (mid * mid <= x) {
left = mid;
} else {
right = mid;
}
}
return left;
}
}