LeetCode 69. Sqrt(x)
来源:互联网 发布:灵族捏脸数据 编辑:程序博客网 时间:2024/06/11 19:47
题意
求
思路
使用二分法求解,其中注意,
代码
class Solution {public: int mySqrt(int x) { if(x <= 0) return 0; int l = 1, r = x; while(l < r){ int mid = (l + r + 1) / 2; if(mid > x / mid){ r = mid - 1; } else{ l = mid; } } return l; }};
阅读全文
0 0
- 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)
- LeetCode-69.Sqrt(x)
- 整理linux基础网络管理
- <HeadFirst设计模式>笔记——命令模式
- cmd下的命令行换行符!
- 重温计算机简史:从石头计数到计算机
- navicat premium 一直报 cannot create oci environment
- LeetCode 69. Sqrt(x)
- python django web开发之准备
- IDEA打包
- Extjs4中combo的联动选择
- 深入了解MyBatis参数
- Cartographer中的branch and bound算法的理解
- 移动硬盘无法识别,磁盘图标不显示解决方法介绍
- VAO VBO IBO大乱炖
- Tiny4412 Android5.0 定制MTP显示的名字