Created
March 24, 2016 23:02
-
-
Save jianminchen/1fd8c8e9acdc72f18d10 to your computer and use it in GitHub Desktop.
Two string - C++ - set class, insert, find, end functions
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 <vector> | |
#include <list> | |
#include <map> | |
#include <set> | |
#include <queue> | |
#include <deque> | |
#include <stack> | |
#include <bitset> | |
#include <algorithm> | |
#include <functional> | |
#include <numeric> | |
#include <utility> | |
#include <sstream> | |
#include <iostream> | |
#include <iomanip> | |
#include <cstdio> | |
#include <cmath> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
int main() | |
{ | |
string A,B; | |
int T; | |
cin>>T; | |
while(T--) | |
{ | |
cin>>A>>B; | |
set<char>S; | |
int n=A.length(); | |
int m=B.length(); | |
for(int i=0;i<n;i++) | |
S.insert(A[i]); | |
bool flag=false; | |
for(int j=0;j<m;j++) | |
if(S.find(B[j])!=S.end()) | |
{ | |
flag=true; | |
break; | |
} | |
if(flag) | |
cout<<"YES"<<endl; | |
else | |
cout<<"NO"<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment