You are viewing a single comment's thread. Return to all comments →
c++
int beautifulTriplets(int d, vector<int> arr) { unordered_set<int> s(arr.begin(), arr.end()); int c = 0; for (size_t i = 0; i < arr.size(); i++) { if (s.count(arr[i]) && s.count(arr[i] + d) && s.count(arr[i] + 2 * d)) { c++; } } return c; }
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++