给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2+ b2 = c。
class Solution {
public boolean judgeSquareSum(int c) {
int i=0;
int j=(int)Math.sqrt(c);
while(i<=j){
if(i*i+j*j==c){
return true;
}else if(i*i+j*j>c){
j--;
}else{
i++;
}
}
return false;
}
}
448

被折叠的 条评论
为什么被折叠?



