leetcode 367[easy]----Valid Perfect Square
难度:easy
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
思路: 此题的思路与 69. Sqrt(x) 一摸一样,用两分法。
链接: http://blog.****.net/fawnzou2017/article/details/78698178。
high= nums+1的初始设置,是因为要考虑num=1