Your question is Anagram Finder With Tests. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Milliman Integrate may need to resolve multiple search terms against a terminology dictionary, treating words as matches when they contain exactly the same letters in a different order. Given a dictionary and several query words, return every dictionary word that is an anagram of each query.
The result for each query must preserve the dictionary's original order, including duplicate dictionary entries. A dictionary word matches only when its character counts are identical to the query's counts. Do not return generated permutations that are absent from the dictionary.
Implement find_anagrams(dictionary, queries), where dictionary and queries are lists of lowercase English strings. Return a list whose ith element contains all dictionary words that are anagrams of queries[i].
Build reusable lookup information so that the dictionary is processed once rather than rescanned for every query.
def find_anagrams(dictionary, queries):