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

来源:互联网 发布:金十数据直播间 编辑:程序博客网 时间:2024/06/01 08:17

难度: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: 16Returns: True

Example 2:

Input: 14Returns: False

思路: 此题的思路与 69Sqrt(x) 一摸一样,用两分法。

           链接: http://blog.csdn.net/fawnzou2017/article/details/78698178。

           high= nums+1的初始设置,是因为要考虑num=1

        


原创粉丝点击