367. Valid Perfect Square

二分法
class Solution(object):
    def isPerfectSquare(self, num):
        """
        :type num: int
        :rtype: bool
        """
        left,right=0,num
        while left<=right:
            mid=left+(right-left)/2 
            t=mid*mid
            if t==num: return True
            elif (t

你可能感兴趣的:(367. Valid Perfect Square)