Created
March 24, 2016 17:35
-
-
Save jianminchen/13c2d3832f1cbd53433c to your computer and use it in GitHub Desktop.
Two string - C++ solution - memset, for loop, type conversion a[i] - 'a', and break statement
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<cstdio> | |
#include<cstring> | |
#include<string> | |
#include<cctype> | |
#include<cstdlib> | |
#include<algorithm> | |
#include<bitset> | |
#include<vector> | |
#include<list> | |
#include<deque> | |
#include<queue> | |
#include<map> | |
#include<set> | |
#include<stack> | |
#include<cmath> | |
#include<sstream> | |
#include<fstream> | |
#include<iomanip> | |
#include<ctime> | |
#include<complex> | |
#include<functional> | |
#include<climits> | |
#include<cassert> | |
#include<iterator> | |
using namespace std; | |
int m[27]; | |
int t; | |
string a; | |
string b; | |
int main(){ | |
cin >> t; | |
while (t--){ | |
cin >> a >> b; | |
for (int i = 0; i < a.size(); i++){ | |
m[a[i] - 'a']++; | |
} | |
bool ok = 0; | |
for (int i = 0; i < b.size(); i++){ | |
if (m[b[i] - 'a']){ | |
ok = 1; | |
break; | |
} | |
} | |
if (ok){ | |
puts("YES"); | |
} | |
else{ | |
puts("NO"); | |
} | |
memset(m, 0, sizeof(m)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment