633.Sum of Square Numbers
Example 1:
Input: 5
Output: True
Explanation: 1 * 1 + 2 * 2 = 5
Example 2:
Input: 3
Output: Falseclass Solution {
bool isSquare(int n)
{
int tmp=sqrt(n);
return tmp*tmp == n;
}
public:
bool judgeSquareSum(int c) {
for(int i=0;i<=sqrt(c);i++)
{
if(isSquare(c-i*i) ) return true;
}
return false;
}
};Last updated