-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtwo_strings.py
More file actions
44 lines (23 loc) · 712 Bytes
/
two_strings.py
File metadata and controls
44 lines (23 loc) · 712 Bytes
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
# Solution of the challenge proposed on Hackerrank at shorturl.at/myDOW
# In order to know whether two strings share a common substring, it suffices to determine if they have
# at least one common letter. This implies that, after converting them into sets, their intersection
# should not be empty.
import math
import random
import re
import sys
def twoStrings(s1, s2):
str1 = set(s1)
str2 = set(s2)
intr = str1.intersection(str2)
if intr != set():
return "YES"
else:
return "NO"
if __name__ == '__main__':
q = int(input())
for q_itr in range(q):
s1 = input()
s2 = input()
result = twoStrings(s1, s2)
print(result)