https://leetcode.com/problems/sum-of-square-numbers/#/description
给一个数字c,判断是否满足a2 + b2 = c
双指针,end最大为c开根号,beg最小为0.判断当前beg和end是否满足,然后相应移动beg或者end
public class Solution {
public boolean judgeSquareSum(int c) {
int beg = 0;
int end = (int) Math.sqrt(c);
while (beg <= end) {
int target = beg * beg + end * end;
if (target > c) {
end--;
} else if (target < c) {
beg++;
} else {
return true;
}
}
return false;
}
}