c++ | using trie | low T.C.
```\nclass node{\npublic:\n    node links[26];\n    bool flag=false;\n};\n\nclass MagicDictionary {\n    node root;\npublic:\n    MagicDictionary() {\n        r
```\nclass node{\npublic:\n    node* links[26];\n    bool flag=false;\n};\n\nclass MagicDictionary {\n    node* root;\npublic:\n    MagicDictionary() {\n        root=new node();\n    }\n    \n    void addKey(string s) {\n        node* temp=root;\n        \n        for(int i=0; i<s.length(); i++) {\n            if(temp->links[s[i]-\'a\']==NULL) temp->links[s[i]-\'a\']=new node();\n            temp=temp->links[s[i]-\'a\'];\n        }\n        \n        temp->flag=true;\n    }\n    \n    void buildDict(vector<string> dictionary) {\n        for(auto word:dictionary) {\n            addKey(word);\n        }\n    }\n    \n    bool util(string s, node* temp, int i=0, bool changed=false) {\n        if(i==s.length() && temp->flag && changed) return true;\n        if(i==s.length()) return false;\n        \n        if(changed) {\n            if(!temp->links[s[i]-\'a\']) return false;\n            else return util(s, temp->links[s[i]-\'a\'], i+1, changed);\n        } else {\n            for(int j=0; j<26; j++) {\n                if(s[i]!=\'a\'+j && temp->links[j] && util(s, temp->links[j], i+1, !changed)) return true;\n            }\n            \n            if(temp->links[s[i]-\'a\'] && util(s, temp->links[s[i]-\'a\'], i+1, changed)) return true;\n        }\n        \n        return false;\n    }\n    \n    bool search(string searchWord) {\n        return util(searchWord, root);\n    }\n};
[]