#633

Sum of Square Numbers

medium · verified · 36.7% accepted · 3,442 likes · top 14%

math · two pointers · binary search

⊣ practice⊣ quiz⊣ open on leetcode ↗

Description

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
Explanation: 1 * 1 + 2 * 2 = 5

Example 2:

Input: c = 3
Output: false

Solution