#633

Sum of Square Numbers

expert · 1060 · lc medium +32 · verified · 36.7% accepted · 3,442 likes · top 14%

play →

Description

Given a non-negative integer c, determine whether two non-negative integers a and b exist such that a² + b² = c. Return true if so, otherwise false.

Example 1:

Input: c = 5
Output: true
Explanation: 1 * 1 + 2 * 2 = 5

Example 2:

Input: c = 3
Output: false

Code

1
2
3