Dictionary with wildcard lookups
Write a class WildcardDictionary that stores words and answers pattern lookups.
add(word)storesword.match(pattern)returnsTrueif some stored word has the same length aspatternand agrees with it at every position, where a.in the pattern stands for any single letter; otherwise it returnsFalse.
Words use lowercase a–z; words and patterns have 1 to 20 characters, and the same word may be added more than once.
The tests call the provided run_dictionary(ops): it applies each operation in order and returns the list of results (None for add, shown as null).
Examples
run_dictionary([["add","cat"],["add","cot"],["match","cat"],["match","c.t"],["match","cut"],["match","c.."],["match","ca"]])→[null,null,true,true,false,true,false]run_dictionary([["match","a"],["add","a"],["match","a"],["match","."],["match",".."]])→[false,null,true,true,false]run_dictionary([["add","cart"],["match","car"],["match","car."],["match","cart."],["match","...."]])→[null,false,true,false,true]