题解 | #求平方根#
求平方根
https://www.nowcoder.com/practice/09fbfb16140b40499951f55113f2166c
package main /** * * @param x int整型 * @return int整型 */ func sqrt(x int) int { var l int64 = 0 var r = int64(x) for l <= r { mid := (l + r) / 2 if int64(x) >= mid*mid { l = mid + 1 } else { r = mid - 1 } } return int(r) // write code here }