【leetcode】69. Sqrt(x)【M】【74】
来源:互联网 发布:非诚勿扰交友软件 编辑:程序博客网 时间:2024/05/16 04:44
Implement int sqrt(int x)
.
Compute and return the square root of x.
Subscribe to see which companies asked this question
二分法,最后再加一个处理
这么简单的题目竟然才做。。sigh
class Solution(object): def mySqrt(self, x): start = 1 end = x while start < end: #print start,mid,end mid = (start + end) / 2 res = mid ** 2 if res > x: end = mid - 1 elif res == x: return mid else: start = mid + 1 if start ** 2 > x: start -= 1 return start
0 0
- 【leetcode】69. Sqrt(x)【M】【74】
- LeetCode 69. Sqrt(x)
- LeetCode 69.Sqrt(x)
- LeetCode --- 69. Sqrt(x)
- [Leetcode] 69. Sqrt(x)
- [leetcode] 69.Sqrt(x)
- Leetcode-69.Sqrt(x)
- leetcode--69.sqrt(x)
- LeetCode 69. Sqrt(x)
- leetcode 69. Sqrt(x)
- 【LeetCode】69. Sqrt(x)
- 69. Sqrt(x) LeetCode
- [leetcode] 69. Sqrt(x)
- leetcode 69. Sqrt(x)
- LeetCode 69. Sqrt(x)
- LeetCode 69. Sqrt(x)
- leetcode-69. Sqrt(x)
- [leetcode]69. Sqrt(x)
- iOS App让自己的应用在其他应用中打开列表中显示、iOS把自己的应用添加到”活动“、将PDF文件Open In MyApp
- Slider 使用
- android里TextView加下划线的几种方式
- Python subprocess模块学习总结
- cocos2dx项目在android平台第一次安装的一个奇怪的bug
- 【leetcode】69. Sqrt(x)【M】【74】
- VMWare下ubuntu恢复环境变量
- mysql无法启动
- IntelliJ IDEA 常用快捷键
- pip 命令
- oracle数据库对象
- cocos2dx源码分析:事件监听器EventListener
- 前端基础问题整理
- critical sections 临界区(危险区)