7 line python code

  • 0
    class Solution(object):
        def isPerfectSquare(self, num):
            :type num: int
            :rtype: bool
            n = 1
            while n*n<=num:
                n += 1
            if n**2 == num or (n-1)**2 == num:
                return True
                return False

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.