1
class Solution {
2
public:
3
bool judgeSquareSum(int c) {
4
long long start = 0, end = 0;
5
while (end * end < c) {
6
end++;
7
}
8
long long target = c;
9
while (start <= end) {
10
long long product = start * start + end * end;
11
if (product == target) {
12
return true;
13
} else if (product > c) {
14
end--;
15
} else {
16
start++;
17
}
18
}
19
return false;
20
}
21
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0