```
public class Solution {
public boolean judgeSquareSum(int c) {
if(c==0) return true;
int i=0;
int j=(int)Math.sqrt(c);
while(i<=j){
int num=i*i+j*j;
if(num==c){
return true;
}else if(num<c){
i++;
}else{
j--;
}
}
return false;
}
}
```