Count Square Sum Triples LeetCode solution in Java

1
class Solution {
2
public int countTriples(int n) {
3
int c = 0;
4
for (int i = 1; i <= n; i++) {
5
for (int j = i + 1; j <= n; j++) {
6
int sq = (i * i) + (j * j);
7
int r = (int) Math.sqrt(sq);
8
if (r * r == sq && r <= n) c += 2;
9
}
10
}
11
return c;
12
}
13
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0