Sum of Square Numbers – LeetCode 633
Problem
Description
Given a non-negative integer c, your task is to decide whether there’re two integers a and b such that $a^2 + b^2 = c$.
Answer
Original
Code
1 | class Solution { |
思路
简单的在可行域中枚举。时间复杂度$O(\sqrt{n}log{n})$,空间复杂度$O(1)$。
耗时$4$ ms,排名$27.30\%$
Better
思路
还没看到更好的思路