LeetCodeDiary

A Diary for solving LeetCode problems

View on GitHub
class Solution:
    def judgeSquareSum(self, c: int) -> bool:
        b = 0
        t = c - b**2
        while t >= 0 :
            a = math.sqrt(t)
            if a % 1 == 0:
                return True
            else:
                b += 1
                t = c - b**2
        return False

数学 中等 每日一题

遍历检查就完事了

https://leetcode-cn.com/problems/sum-of-square-numbers/