4 line Python. Beats 100%


  • 0
    D
        def judgeSquareSum(self, c):
            for i in range(int(math.sqrt(c)) + 1):
                if math.sqrt(c - i*i).is_integer():
                    return True
            return False
    

Log in to reply
 

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