-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringComparison.py
More file actions
55 lines (42 loc) · 1.17 KB
/
StringComparison.py
File metadata and controls
55 lines (42 loc) · 1.17 KB
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
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'matchingStrings' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts following parameters:
# 1. STRING_ARRAY stringList
# 2. STRING_ARRAY queries
#
def matchingStrings(stringList, queries):
# Write your code here
result = []
stringList_count = len(stringList)
queries_count = len(queries)
for i in range(queries_count):
sum=0
for j in range(stringList_count):
if queries[i] == stringList[j]:
sum+=1
result.append(sum)
return result
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
stringList_count = int(input().strip())
stringList = []
for _ in range(stringList_count):
stringList_item = input()
stringList.append(stringList_item)
queries_count = int(input().strip())
queries = []
for _ in range(queries_count):
queries_item = input()
queries.append(queries_item)
res = matchingStrings(stringList, queries)
fptr.write('\n'.join(map(str, res)))
fptr.write('\n')
fptr.close()