633. Sum of Square Numbers

Information

  • Diffculty: Easy

  • Created: 2019-09-01 17:53:30

  • Last Motified: 2019-09-01 17:53:30

Solution

class Solution:
    def judgeSquareSum(self, c: int) -> bool:
        mapping = set()
        for i in range(c + 1):
            n = i * i
            if n > c:
                return False
            mapping.add(n)
            if c - n in mapping:
                return True