leetcode :Binary Search:Valid Perfect Square(367)
来源:互联网 发布:php开源站群管理系统 编辑:程序博客网 时间:2024/06/07 07:34
Given a positive integer num, write a function which returns True if num is a perfect square else False.
Note: Do not use any built-in library function such as sqrt.
Example 1:
Input: 16
Returns: True
Example 2:
Input: 14
Returns: False
class Solution {public: bool isPerfectSquare(int num) { if (num == 1) return true; long x = num / 2, t = x * x; while (t > num) { x /= 2; t = x * x; } for (int i = x; i <= 2 * x; ++i) { if (i * i == num) return true; } return false; }};
0 0
- leetcode :Binary Search:Valid Perfect Square(367)
- Binary search (2) -- Heaters, Valid Perfect Square
- Binary Search:367. Valid Perfect Square
- LeetCode 367 Valid Perfect Square
- leetcode 367 Valid Perfect Square
- LeetCode[367] Valid Perfect Square
- LeetCode 367 Valid Perfect Square
- Leetcode 367 Valid Perfect Square
- LeetCode-Easy部分中标签为 Binary Search 367. Valid Perfect Square
- LeetCode:Valid Perfect Square
- 【Leetcode】valid perfect square
- [leetcode] Valid Perfect Square
- leetcode---Valid Perfect Square
- LeetCode -- Valid Perfect Square
- LEETCODE--Valid Perfect Square
- LeetCode : Valid Perfect Square
- [leetcode-367]Valid Perfect Square(java)
- LeetCode 第 367 题 (Valid Perfect Square)
- java线程安全问题之静态成员变量、实例成员变量、局部变量
- Android开发中常用ADB命令总结
- Java中成员变量和属性之间的关系
- Android Studio 友盟多渠道打包
- Error:Unable to start the daemon process. This problem might be caused by incorrect configuration of
- leetcode :Binary Search:Valid Perfect Square(367)
- java多态
- ssd训练500x500的数据
- 面试题 最长回文子串
- kie-server java client json for drools6.4
- Makefile选项CFLAGS,LDFLAGS,LIBS
- ASP.NET网络编程中经常用到的27个函数集
- android中点击输入框时整个布局被上移的解决办法
- java设计模式进阶_memento