9
void insert(string &s) {12
if (!cur->children[c - 'a']) {13
cur->children[c - 'a'] = new node();15
cur = cur->children[c - 'a'];23
void buildDict(vector<string> dictionary) {24
for (string &s : dictionary) insert(s);27
bool find(int i, string &s, node *cur, int mismatch) {28
if (i == s.size() and mismatch == 0) return cur->end;29
if (mismatch < 0) return false;30
if ((!cur || i == s.size()) and mismatch != 0) return false;34
for (int j = 0; j < 26; j++) {35
if (cur->children[j]) {37
ans |= find(i + 1, s, cur->children[j], mismatch - 1);39
ans |= find(i + 1, s, cur->children[j], mismatch);45
bool search(string searchWord) {46
return find(0, searchWord, root, 1);