C++ Solution || Trie || Backtracking.
\nclass Trie{\n    \npublic:\n    Trie *child[26];\n    bool isEnd;\n    \n    Trie() {\n        isEnd = false;\n        for(int i = 0; i<26; i++){\n           
```\nclass Trie{\n    \npublic:\n    Trie *child[26];\n    bool isEnd;\n    \n    Trie() {\n        isEnd = false;\n        for(int i = 0; i<26; i++){\n            child[i] = NULL;\n        }\n        \n    }\n    \n    void insert(string word) {\n        \n        Trie *curr = this;\n        int len = word.length();\n        for(int i = 0; i<len; i++){\n            int index = word[i] - \'a\';\n            if(curr->child[index]==NULL)\n                curr->child[index] = new Trie();\n            curr = curr->child[index];\n        }\n        curr->isEnd = true;\n           \n    }\n    \n    bool search(string word) {\n        Trie *curr = this;\n        int len = word.length();\n        for(int i = 0; i<len; ++i){\n            int index = word[i] - \'a\';\n            if(curr->child[index] == NULL)\n                return false;\n            curr = curr->child[index];\n        }\n        if(curr->isEnd ==false)\n            return false;\n        return true;\n    }   \n};\n\nclass Solution {\n    \npublic:\n    string mxStr = "";\n    bool isEmpty(Trie *root){\n        for(int i = 0; i<26; i++){\n            if(root->child[i] != NULL)\n                return false;\n        }\n        return true;\n    }\n    void backT(Trie *root, string &ans){\n        if(root->isEnd == false || isEmpty(root)){\n            \n            return;\n        }\n        else{\n            for(int i = 0; i<26; i++){\n                if(root->child[i]!=NULL){\n                    if(root->child[i]->isEnd == false)\n                        continue;// avoid useless call.\n                    ans.push_back(\'a\'+i);\n                    if(mxStr.length()<ans.length())\n                        mxStr = ans;\n                    backT(root->child[i], ans);\n\t\t\t\t\t//backtracking.\n                    ans.pop_back();\n                }\n            }\n        }\n    }\n    string longestWord(vector<string>& words) {\n        Trie *root = new Trie();\n        for(auto w :words){\n            root->insert(w);\n        }\n        string ans = "";\n        for(int i = 0; i<26; i++){\n            if(root->child[i]!=NULL){\n                if(root->child[i]->isEnd == false){\n                    continue; //despite backtracking The mxStr is single direction so avoid useless call.\n                }\n                ans.push_back(\'a\'+i);\n                if(mxStr.length()<ans.length())\n                    mxStr = ans;\n                backT(root->child[i], ans);\n                // Backtracking.\n                ans.pop_back();\n            }\n                \n        }\n        return mxStr;\n        \n    }\n};\n```
['Backtracking', 'Depth-First Search', 'Trie']