@@ -0,0 +1,891 @@
+/**%0A * %0A */%0Apackage algorithms.implementation;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Scanner;%0Aimport java.util.Set;%0A%0A/**%0A * Challenge: https://www.hackerrank.com/challenges/beautiful-triplets/%0A * %0A * TODO: Implement this in Constant space%0A * %0A * @author Sudharsanan Muralidharan%0A */%0Apublic class BeautifulTriplets %7B%0A  public static void main(String%5B%5D args) %7B%0A    Scanner in = new Scanner(System.in);%0A    int n = in.nextInt();%0A    int d = in.nextInt();%0A    int%5B%5D arr = new int%5Bn%5D;%0A    Set%3CInteger%3E numbers = new HashSet%3CInteger%3E();%0A    int count = 0;%0A%0A    for (int i = 0; i %3C n; i++) %7B%0A      arr%5Bi%5D = in.nextInt();%0A      numbers.add(arr%5Bi%5D);%0A    %7D%0A%0A    for (int i = 0; i %3C n; i++) %7B%0A      int sec = arr%5Bi%5D + d;%0A      int next = sec + d;%0A      if(numbers.contains(sec) && numbers.contains(next)) %7B%0A        count++;%0A      %7D%0A    %7D%0A    %0A    System.out.println(count);%0A    in.close();%0A  %7D%0A%7D%0A

Add solution for BeautifulTriplets