• + 0 comments
     
     public static int beautifulTriplets(int d, List<Integer> arr) {
        // Write your code here
         int triplets=0;
         for(int i=0;i<arr.size();i++){
             int sum = d+arr.get(i);
             if(arr.contains(sum)){
                sum=sum+d;
                if(arr.contains(sum)){
                    triplets++;
                }
             }
        }
            return triplets;
         }
        
    
    }
    

    `