Sum of Square Numbers

Given a non-negative integer c, decide whether there are two integers a and b such that a^2 + b^2 = c. Return true if such integers exist, otherwise return false.

Example 1
Inputc = 5
Outputtrue
1 * 1 + 2 * 2 = 5, so integers a = 1 and b = 2 satisfy the equation.
Example 2
Inputc = 3
Outputfalse
There are no two integers whose squared sum equals 3.

Constraints

  • 0 <= c <= 2^31 - 1

Asked at 7 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate