Created
March 24, 2016 23:20
-
-
Save jianminchen/f4b6dcea9936347192e9 to your computer and use it in GitHub Desktop.
Two string - C++ if(a[i] && b[i]) 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 <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include<string> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int t; | |
cin>>t; | |
while(t--) | |
{ | |
int a[101]={0},b[101]={0}; | |
string s1,s2; | |
cin>>s1>>s2; | |
for(int i=0;i<s1.length();i++) | |
a[s1[i]-'a']++; | |
for(int i=0;i<s2.length();i++) | |
b[s2[i]-'a']++; | |
int flag=0; | |
for(int i=0;i<26;i++) | |
{ | |
if(a[i] && b[i]) | |
flag=1; | |
} | |
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