class Solution(object):
def isPerfectSquare(self, num):
"""
:type num: int
:rtype: bool
"""
# 69的进阶,二分查找法
l, r = 1, num
while l<=r:
mid = l + ((r-l)>>1)
if mid * mid < num:
l = mid +1
elif mid * mid > num:
r = mid -1
else:
return True
return False