There is a collection of input strings and a collection of query strings. For each query string, determine how many times it occurs in the list of input strings. Return an array of the results.
Complete the function matchingStrings in the editor below. The function must return an array of integers representing the frequency of occurrence of each query string in strings.
matchingStrings has the following parameters:
The first line contains and integer , the size of .
Each of the next lines contains a string .
The next line contains , the size of .
Each of the next lines contains a string .
Constraints
1 <= n <= 1000
1 <= q <= 1000
1 <= |strings[i]|,|queries[i]| <= 20
def matchingStrings(strings, queries):
s = strings
q = queries
answer = [0 for i in range(len(q))]
for i in range(len(q)):
for j in range(len(s)):
if q[i] == s[j]:
answer[i] += 1
return answer
이것도 범위가 작아서 하나씩 비교해줬다.
queries[i]가 strings[i]와 같으면 갯수를 하나씩 더해줬다.