package leetcode;

/**
 * https://leetcode.com/problems/count-good-triplets/
 */
public class Problem1534 {
    public int countGoodTriplets(int[] arr, int a, int b, int c) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1534 prob = new Problem1534();
        System.out.println(prob.countGoodTriplets(new int[]{3,0,1,1,9,7}, 7, 2, 3)); // 4
        System.out.println(prob.countGoodTriplets(new int[]{1,1,2,2,3}, 0, 0, 1)); // 0
    }
}

package leetcode;

/**
 * https://leetcode.com/problems/count-good-triplets/
 */
public class Problem1534 {
    public int countGoodTriplets(int[] arr, int a, int b, int c) {
        int answer = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                for (int k = j + 1; k < arr.length; k++) {
                    if (Math.abs(arr[i] - arr[j]) <= a &&
                        Math.abs(arr[j] - arr[k]) <= b &&
                        Math.abs(arr[i] - arr[k]) <= c) {
                        answer++;
                    }
                }
            }
        }
        return answer;
    }
}

Solve problem 1534