You are viewing a single comment's thread. Return to all comments →
int beautifulTriplets(int d, vector arr) { unordered_set t; unordered_set :: iterator it; int count = 0;
for(int i = 0; i < arr.size(); ++i){ if(find(t.begin(), t.end(), arr[i]) == t.end()){ t.insert(arr[i]); } } for(it = t.begin(); it != t.end(); it++){ if( (find(t.begin(), t.end(), *it + d) != t.end()) && (find(t.begin(), t.end(), *it + d*2) != t.end())){ count ++; } } return count;
} why the test case 10 is failing 10 3 1, 6, 7, 7, 8, 10 , 12, 13, 14, 19 expected answer is 2 but only 1 possible triplet can be found here...
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 →
int beautifulTriplets(int d, vector arr) { unordered_set t; unordered_set :: iterator it; int count = 0;
} why the test case 10 is failing 10 3 1, 6, 7, 7, 8, 10 , 12, 13, 14, 19 expected answer is 2 but only 1 possible triplet can be found here...