class Solution{
public:
bool judgeSquareSum(int c){
for(int i = 0; i <= sqrt(c); i++){
int sum_left = (c  i*i);
if(sqrt(sum_left) == floor(sqrt(sum_left))){
for(int j = i; j <= sqrt(sum_left); j++){
if(i*i + j*j > c)
break;
if(i*i + j*j == c)
return true;
}
}
}
return false;
}
};
F
faiz89
@faiz89
0
Reputation
2
Posts
46
Profile views
0
Followers
0
Following
Posts made by faiz89

C++ solution. Similar to other solutions.

RE: C++ Solution, 12ms
@zhaotianzju "swap(perm[i], perm[begin]);" is not really needed. It would work without it too.