• + 0 comments
    def beautifulTriplets(d, arr):
        count = 0
        set_of_numbers = set(arr)
        for n in arr:
            fir = n
            sec = fir + d
            thi = sec + d
            if sec in set_of_numbers and thi in set_of_numbers:
                count += 1
        return count