Zepruv › Coding problems

Sum of Square Numbers

Medium · Math, Two Pointers, Binary Search

Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.

Example 1

Input: c = 5
Output: true

1 * 1 + 2 * 2 = 5

Example 2

Input: c = 3
Output: false

Constraints

Starter code (python)

class Solution(object):
    def judgeSquareSum(self, c):
        """
        :type c: int
        :rtype: bool
        """
        

Related problems

Previous: Course Schedule III · Next: Exclusive Time of Functions · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.