Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 515 Bytes

633.md

File metadata and controls

33 lines (22 loc) · 515 Bytes

633 Sum of Square Numbers

Description

link


Solution

  • See Code

Code

class Solution:
    def judgeSquareSum(self, c: int) -> bool:
        sq = set()
        count = int(math.sqrt(c))
        # use (count + 1) because first index is 0
        for i in range(count + 1):
            sq.add(i ** 2)

        for n in sq:
            if c - n in sq:
                return True

        return False