You are viewing a single comment's thread. Return to all comments →
Thank you for the insight! Since many others are posting code for this problem, I'd like to suggest that c++ isn't too far from python this time :-)
int n, d; cin >> n >> d; vector<int> vals(n); for (auto& val : vals) cin >> val; auto exists = [&](int val) { return binary_search(begin(vals), end(vals), val); }; auto result = count_if( begin(vals), end(vals), [&](int val) { return exists(val + d) && exists(val + 2 * d); }); cout << result << endl;
`
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 →
Thank you for the insight! Since many others are posting code for this problem, I'd like to suggest that c++ isn't too far from python this time :-)
`