forked from adityabisoi/ds-algo-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.cpp
43 lines (31 loc) · 862 Bytes
/
solution.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
// Implementation Part
string twoStrings(string s1, string s2) {
// traverse each letter of string s1
for(int i = 0; i < s1.size(); i++){
// check if current letter of s1 found in s2
// if found that means we have atleast one length substring
// npos ---> not found
if(s2.find(s1[i]) != string::npos)
return "YES";
}
return "NO";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int q;
cin >> q;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
for (int q_itr = 0; q_itr < q; q_itr++) {
string s1;
getline(cin, s1);
string s2;
getline(cin, s2);
string result = twoStrings(s1, s2);
fout << result << "\n";
}
fout.close();
return 0;
}