1 class Solution: 2 def isPerfectSquare(self, num: int) -> bool: 3 if num==1: 4 return True 5 r=num 6 while r>num/r: 7 r=(r+num/r)//2 8 if num==r**2: 9 return True 10 else: 11 return False
When execution: 48 ms, beat the 74.72% of users in all Python3 submission
Memory consumption: 13.8 MB, beat the 5.30% of users in all Python3 submission
——2019.9.25