Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 24, 2016 17:38
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 jianminchen/484bd7705844da26ecd0 to your computer and use it in GitHub Desktop.
Save jianminchen/484bd7705844da26ecd0 to your computer and use it in GitHub Desktop.
Two string - C++ solution - namespace std, >>, string class, set<char>, auto, &x, for(auto &x: A), modern C++ style
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
int main() {
int T; cin >> T;
while (T--) {
string A, B; cin >> A >> B;
set<char> S;
for (auto &x : A)
S.insert(x);
bool ok =false;
for (auto &x : B)
if (S.count(x))
ok = true;
if (ok)
cout << "YES\n";
else
cout << "NO\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment