Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 24, 2016 23:02
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/1fd8c8e9acdc72f18d10 to your computer and use it in GitHub Desktop.
Save jianminchen/1fd8c8e9acdc72f18d10 to your computer and use it in GitHub Desktop.
Two string - C++ - set class, insert, find, end functions
#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