您的位置:首页 > Web前端

leetcode 367[easy]----Valid Perfect Square

2017-12-18 16:38 302 查看
难度: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.csdn.net/fawnzou2017/article/details/78698178。
           high= nums+1的初始设置,是因为要考虑num=1

        
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode 两分法