• + 0 comments
    def beautifulTriplets(d, arr):
        # Write your code here
        list2=[]
        for i in arr:
            list1=[]
            a=i
            for j in arr[1:]:
                if len(list1)<3:
                    if j-a==d:
                        if a not in list1:
                            list1.append(a)
                        list1.append(j)
                        a=j
            if len(list1)==3:          
                list2.append(list1)
        # print(list2)    
        return len(list2)