• + 0 comments

    Python one-liner:

    def beautifulTriplets(d, arr):
        return sum(arr.count(n) * arr.count(n + d) * arr.count(n + d + d) for n in set(arr))