Implement int sqrt(int x)
.
Compute and return the square root of x.
思路:调用库函数math.sqrt
代码如下(已通过leetcode)
public class Solution {
public int mySqrt(int x) {
return (int)Math.sqrt(x);
}
}
Implement int sqrt(int x)
.
Compute and return the square root of x.
思路:调用库函数math.sqrt
代码如下(已通过leetcode)
public class Solution {
public int mySqrt(int x) {
return (int)Math.sqrt(x);
}
}