Here\'s my solution that is easier to understand in C++
int beautifulTriplets(int d, vector arr) { int ctr=0; int j=0,k=0; vector&l