class Solution {
public boolean judgeSquareSum(int c) {
int i = 0, 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;
}
}
Leetcode两数平方和
最新推荐文章于 2021-01-07 16:02:46 发布