leetcode每日一题——69
public static int  mySqrt(int  x){
if(x<=0)return&nbsp;0;
int&nbsp;low=1,high=x;
while&nbsp;(low<=high)&nbsp;{
long&nbsp;mid=(high-low)/2+low;
if&nbsp;(mid*mid==x)&nbsp;{
return&nbsp;(int)mid;
}else&nbsp;if(mid*mid<x)&nbsp;{
low=(int)mid+1;
}else&nbsp;{
high=(int)mid-1;
}
}
if&nbsp;(high*high<x)&nbsp;{
return&nbsp;(int)high;
}else&nbsp;{
return&nbsp;(int)low;
}
}
}
全部评论

相关推荐

04-28 13:00
已编辑
门头沟学院 Java
啥都ac:项目主要是能讲清楚核心链路技术选型对比方案量化结果等等吧 是否真实做过真实存在不太重要 当然编的项目能做到这种水平也付出了精力了
找工作的破防时刻
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务