Build a dictionary that can answer whether a query word can match any stored word after changing exactly one character. Pattern focus: Wildcard Search with Trie (Add and Search Words). A trie-backed DFS can test one-character substitutions efficiently.
dictionary = stored words, queries = lookup words
boolean results for each query
Example 1:
Input:
dictionary = ["hello","leetcode"] queries = ["hello","hhllo","hell","leetcoded"]
Output:
[false,true,false,false]
Explanation:
Only hhllo differs from hello by exactly one character.
Example 2:
Input:
dictionary = ["magic","trie"] queries = ["magix","magic","tries"]
Output:
[true,false,false]
Explanation:
Exact matches are not enough; one character must change.
Example 3:
Input:
dictionary = ["a","b"] queries = ["c","a"]
Output:
[true,true]
Explanation:
A single-character substitution is enough to match either stored word.