You are viewing a single comment's thread. Return to all comments →
C++ Solution
int beautifulTriplets(int d, vector<int> arr) { int res = 0; for(auto it = arr.begin(); it < arr.end(); it++) { auto a = find(it+1, arr.end(), *(it)+d); if(a != arr.end()) { auto b = find(a+1, arr.end(), *(a)+d); if(b != arr.end()) res++; } } return res; }
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Triplets
You are viewing a single comment's thread. Return to all comments →
C++ Solution