Watto and Mechanism
HardRating 2000CodeforcesString Algorithms (KMP, Z, Hashing)
Approach hintTry it first, then revealHide
Insert the polynomial hash of every stored string into a set. For a query, change one position to each of the other two letters, updating the hash in O(1) per change; double hashing keeps collisions unlikely.