Skip to content

Instantly share code, notes, and snippets.

@ilpropheta
Created July 16, 2016 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilpropheta/21a92ae8ca55f246d14b8168ce0bbaf2 to your computer and use it in GitHub Desktop.
Save ilpropheta/21a92ae8ca55f246d14b8168ce0bbaf2 to your computer and use it in GitHub Desktop.
int N, K;
cin >> N >> K;
unordered_set<int> input;
copy_n(istream_iterator<int>(cin), N, inserter(input, end(input)));
cout << count_if(begin(input), end(input), [&](int currElem){
return input.count(currElem+K);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment