Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-12_01-47-18.png
30.7 KB
#N1925. Count Square Sum Triples
problem link

#solution
class Solution {
public int countTriples(int n) {
int count = 0;
for (int i = 1; i < n; i++){
for (int j = i + 1; j < n; j++){
int square = i * i + j * j;
int c = (int) Math.sqrt(i * i + j * j);
if (c <= n && c * c == square) count++;
}
}

return count*2;
}
}