Skip to content

Commit efd1d5d

Browse files
authored
Create Solution.java
1 parent 86cbaaf commit efd1d5d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public boolean judgeSquareSum(int c) {
3+
int i = 0, j = (int) Math.sqrt(c);
4+
while (i <= j) {
5+
int s = i * i + j * j;
6+
if (s < c) {
7+
++i;
8+
} else if (s > c) {
9+
--j;
10+
} else {
11+
return true;
12+
}
13+
}
14+
return false;
15+
}
16+
}

0 commit comments

Comments
 (0)