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 Output: true
Example 2:
Input: 14 Output: false
# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
"""
Soultions:
这里使用的思路是二分搜索
左右各一个指针
"""
class ValidPerfectSquare(object):
def isPerfectSquare(self, num):
"""
:type num: int
:rtype: bool
"