Leetcode 633 Solution
This article provides solution to leetcode question 633 (sum-of-square-numbers)
Access this page by simply typing in "lcs 633" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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