Skip to content

Commit

Permalink
1534
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 3, 2022
1 parent 9ac5030 commit 2132066
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions E_1534_CountGoodTriplets.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Solution {
public int countGoodTriplets(int[] arr, int a, int b, int c) {
int sonuc=0;
for(int i=0;i<arr.length-2; i++) {
for (int j = i+1; j < arr.length-1; j++) {
if(!(Math.abs(arr[i] - arr[j]) <= a)) continue;
for (int k = j+1; k < arr.length; k++) {
if ( Math.abs(arr[j] - arr[k]) <= b && Math.abs(arr[i] - arr[k]) <= c) {
sonuc++;

}
}
}
} return sonuc;
}
}

0 comments on commit 2132066

Please sign in to comment.