Given words and a list of queries (prefixes), return for each query the number of words that start with it (a word equal to the query counts). Repeated words count each time.
For words = ["apple", "app", "apt", "bat"] and queries = ["ap", "app", "b", "c"] the answer is [3, 2, 1, 0].
The starter code checks every word for every query. It is correct but too slow for many words and queries.
Example 1
Input:
count_with_prefix(['apple', 'app', 'apt', 'bat'], ['ap', 'app', 'b', 'c'])
Output:
[3, 2, 1, 0]
Example 2
Input:
count_with_prefix([], ['a'])
Output:
[0]
0 <= len(words), len(queries) <= 500001 <= length <= 12, lower-case letters.No results yet
Run your code to check it against the examples, or submit to run every test.