C++ clean readable solution using Trie
```\nclass TrieNode {\npublic:\n    vector children;\n    bool isTerminal;\n    \n    TrieNode() {\n        children.resize(26, NULL);\n        isTerminal = fal
```\nclass TrieNode {\npublic:\n    vector<TrieNode*> children;\n    bool isTerminal;\n    \n    TrieNode() {\n        children.resize(26, NULL);\n        isTerminal = false;\n    }\n};\n\nclass Trie {\n    TrieNode *root;\n    int maxLen;\n    string maxWord;\n\npublic:\n    Trie() {\n        root = new TrieNode();\n        root->isTerminal = true;\n        maxLen = 0;\n    }\n    \n    string getMaxWord() {\n        return maxWord;\n    }\n    \n    void insert(string word) {\n        TrieNode *cur = root;\n        bool flag = true;\n        \n        for (int i = 0; i < word.length(); i++) {\n            char ch = word[i];\n            \n            if (!cur->isTerminal)\n                flag = false;\n            \n            if (cur->children[ch - \'a\'] == NULL)\n                cur->children[ch - \'a\'] = new TrieNode();\n            \n            cur = cur->children[ch - \'a\'];\n        }\n        \n        cur->isTerminal = true;\n        \n        if (flag and word.length() > maxLen) {\n            maxLen = word.length();\n            maxWord = word;\n        }\n    }\n};\n\nclass Solution {\npublic:\n    string longestWord(vector<string>& words) {\n        Trie *myTrie = new Trie();\n        \n        sort(words.begin(), words.end());\n        \n        for (auto word : words)\n            myTrie->insert(word);\n        \n        return myTrie->getMaxWord();        \n    }\n};
[]