Leetcode 633 Solution

This article provides solution to leetcode question 633 (sum-of-square-numbers)

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

Solution

class Solution: def judgeSquareSum(self, c: int) -> bool: if c < 0: return False
if c == 0: return True
i = 0 while i < math.sqrt(c): x = c - i * i y = int(math.sqrt(x))
if y * y == x: return True i += 1 return False