public class Solution { public int mySqrt(int a) { if(a < 2) return a; int start = 2; int end = a/2; int mid = 0; while(start <= end) { mid = start + (end - start)/2; long num = (long)mid*mid; if(num > a) end = mid-1; else if(num < a) start = mid+1; else return mid; } return end; } }
https://blog.csdn.net/weixin_43306331/article/details/103796284
标签:end,int,mid,start,计算,return,平方根,public From: https://www.cnblogs.com/yingpu/p/17796341.html