leetcode-Sqrt(x)
来源:互联网 发布:nba怎么查询端口号 编辑:程序博客网 时间:2024/05/16 18:17
Implement int sqrt(int x)
.
Compute and return the square root of x.
class Solution {public: int sqrt(int x) { if(x <= 1) return x; int l = 0; int r = x; while (l <= r) { int m = l+(r-l)/2; int now = x/m;//avoid overflow if (now < m) r = m-1; else if(now > m) l = m+1; else return m; } return r;//the small one is the answer }};
0 0
- LeetCode: Sqrt(x)
- LeetCode sqrt(x)
- [Leetcode] Sqrt(x)
- LeetCode :Sqrt(x)
- leetcode 53: Sqrt(x)
- [LeetCode] Sqrt(x)
- Leetcode 69 sqrt(x)
- [Leetcode] Sqrt(x)
- leetcode:Sqrt(x)
- 【leetcode】sqrt(int x)
- [LeetCode]Sqrt(x)
- [leetcode]Sqrt(x)
- LeetCode-Sqrt(x)
- [leetcode] Sqrt(x)
- [leetcode] Sqrt(x)
- LeetCode - Sqrt(x)
- leetcode之sqrt(x)
- LeetCode | Sqrt(x)
- Android Selector选择器的使用
- find使用
- B6(B6AC)充电器中文简要说明书
- java引用变量和堆栈
- 网络编程学习笔记(基本套接口选项)
- leetcode-Sqrt(x)
- 中文乱码问题
- Markdown 11种基本语法
- asp.net请求执行过程
- 公司散伙了,总结一下
- java虚拟机——类的生命周期(上)类的加载和连接
- Java+Swing+SQL+Server2005开发酒店管理系统源代码下载
- activeX com 组件开发 一
- Packet Tracer 5.0实验(一) 交换机的基本配置与管理