-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinner_join.py
75 lines (67 loc) · 1.02 KB
/
inner_join.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# author_email="mohamadhayeri9@gmail.com"
# author_git_profile = "https://github.com/mohamadhayeri9"
"""
Explain problem:
We want to do inner join betwen two string. These strings have multiple words.
"""
def inner_join(str1: str, str2: str) -> list:
result = list(set(str1.split()) & set(str2.split()))
return result
def main() -> None:
str1 = """
Emma
Olivia
Ava
Isabella
Sophia
Charlotte
Mia
Amelia
Harper
Evelyn
Abigail
Emily
Elizabeth
Mila
Ella
Avery
Sofia
Camila
Aria
Scarlett
Victoria
Madison
Luna
Grace
Chloe
Penelope
Layla
Riley
Nora
Lily
Eleanor
Hannah
Lillian
Addison
Aubrey
Ellie
Stella
Natalie
Zoe
Leah
Hazel
Violet
Aurora
Savannah
Audrey
Brooklyn
Bella
Claire
Skylar
"""
str2 = "asd dfg"
result = inner_join(str1, str2)
print(result)
if __name__ == "__main__":
main()