[LeetCode]--69. Sqrt(x)
来源:互联网 发布:怎么注册淘宝小号 编辑:程序博客网 时间:2024/06/05 04:39
Implement int sqrt(int x).
Compute and return the square root of x.
我采用的是二分法。每次折中求平方,如果大了就把中值赋给大的,如果小了就把中值赋给小的。
public int mySqrt(int x) { long start = 1, end = x; while (start + 1 < end) { long mid = start + (end - start) / 2; if (mid * mid <= x) { start = mid; } else { end = mid; } } if (end * end <= x) { return (int)end; } return (int) start; }
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)
- 实模式、保护模式和虚拟8086模式
- MyEclipse配置中文版javadoc(API)图文教程
- Codeforces325 D【并查集维护连通性】
- 周期字串
- 有三个线程A、B、C(线程名称或id),循环打印10次ABCABB
- [LeetCode]--69. Sqrt(x)
- <a>标签跳转新页面的各种方式
- ubuntu server 语言设置
- 海量数据问题
- 基于opencv的鱼眼矫正法-棋盘标定
- unicode,ansi,utf-8,unicode big endian编码的区别
- 在线看Android系统源码,那些相见恨晚的几种方案
- java web 项目 无法找到com.mysql.jdbc.Driver的解决方案
- 15: docker networking