标签:tar while log star etc public int logs end
class Solution { public int mySqrt(int x) { if (x < 0) { return -1; } if (x < 2) { return x; } int start = 1; int end = x; while (end - start > 1) { int mid = start + (end - start)/2; if (mid == x / mid) { return mid; } else if (mid > x / mid) { end = mid; } else { start = mid; } } return start; } }
标签:tar while log star etc public int logs end
原文地址:http://www.cnblogs.com/shuashuashua/p/7458297.html