C++ Trie, 96% time 100% memory
\nstruct Node {\n    bool is = false;\n    int children[26] = {0};\n} nodes[301000];\nint cnt = 1;\n\nvoid insert(const string& s) {\n    int cur = 1;\n    for 
```\nstruct Node {\n    bool is = false;\n    int children[26] = {0};\n} nodes[301000];\nint cnt = 1;\n\nvoid insert(const string& s) {\n    int cur = 1;\n    for (char c : s) {\n        if (!nodes[cur].children[c - \'a\']) {\n            ++cnt;\n            memset(&nodes[cnt], 0, sizeof(nodes[cnt]));\n            nodes[cur].children[c - \'a\'] = cnt;\n        }\n        cur = nodes[cur].children[c - \'a\'];\n    }\n    nodes[cur].is = true;\n}\n\nstring res;\nstring s;\n\nvoid dfs(int cur) {\n    for (int i = 0; i < 26; ++i) {\n        int child = nodes[cur].children[i];\n        if (!child || !nodes[child].is) {\n            continue;\n        }\n        s.push_back(\'a\' + i);\n        if (s.size() > res.size()) {\n            res = s;\n        }\n        dfs(child);\n        s.pop_back();\n    }\n}\n\nclass Solution {\npublic:\n    string longestWord(vector<string>& words) {\n        cnt = 1;\n        memset(&nodes[1], 0, sizeof(nodes[1]));\n        for (const string& word : words) {\n            insert(word);\n        }\n        res.clear();\n        s.clear();\n        dfs(1);\n        return res;\n    }\n};\n```
[]