Sum of Square Numbers

Medium Topics Company Tags

Return true if there are integers a and b such that a * a + b * b = c, and false otherwise. Either integer may be zero, and the two integers may be equal.

Example 1:

Input: c = 2

Output: true

Explanation: Choose a = 1 and b = 1, giving 1 * 1 + 1 * 1 = 2.

Example 2:

Input: c = 7

Output: false

Explanation: The only squares no greater than 7 are 0, 1, and 4. No pair of these values sums to 7.

Example 3:

Input: c = 0

Output: true

Explanation: Choose a = 0 and b = 0. Their squares sum to 0.

Constraints:

  • 0 <= c <= 2147483647


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.