landscapemi的博客

###### leetcode :Binary Search： Valid Perfect Square(367)

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;
}
}; 

#### [leetcode] 367. Valid Perfect Square 解题报告

2016-06-26 13:53:04

#### LeetCode 第 367 题 (Valid Perfect Square)

2016-07-12 20:29:35

#### [leetcode: Python]367. Valid Perfect Square

2017-05-13 17:50:36

#### LeetCode Valid Perfect Square（是否是平方数）

2016-06-29 12:03:15

#### leetcode 367 Valid Perfect Square

2016-06-30 21:14:15

#### 第十四周：( LeetCode593) Valid Square（c++）

2017-05-21 23:52:56

#### leetcode perfect square --- 重点

2015-12-01 15:31:04

#### 【LeetCode】Validate Binary Search Tree 解题报告

2014-12-03 16:58:25

#### LeetCode:Valid Perfect Square

2016-06-28 10:14:30

#### Leetcode 367 Valid Perfect Square

2017-09-11 08:47:14

## 不良信息举报

leetcode :Binary Search： Valid Perfect Square(367)