Determine whether a non-negative integer can be written as the sum of two perfect squares.
Given a non-negative integer c, determine whether there exist integers a and b such that:
Return true if such a pair exists, otherwise return false.
You may use the same value for a and b. The integers are not required to be distinct.
c.true if c can be expressed as the sum of two square numbers.false.c.c.true if c = a^2 + b^2 for some integers a and b.false.c fits in a 32-bit signed integer.Example 1
Input
c = 5
Output
true
Explanation
Because .
Example 2
Input
c = 3
Output
false
Explanation
There are no integers a and b such that .
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.