(java) Sqrt(x)

来源:互联网 发布:facebook广告优化师 编辑:程序博客网 时间:2024/05/22 03:28

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);
   
   }
}

0 0
原创粉丝点击