Created
March 24, 2016 17:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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