Java solution with Trie
\nclass Solution {\n    class TrieNode{\n        public char val;\n        public TrieNode[] hash;\n        public boolean isWord;\n        public TrieNode(){\n
```\nclass Solution {\n    class TrieNode{\n        public char val;\n        public TrieNode[] hash;\n        public boolean isWord;\n        public TrieNode(){\n            this.val='\\u0000';\n            this.hash=new TrieNode[26];\n            this.isWord=false;\n        }\n        public TrieNode(char c){\n            this.val=c;\n            this.hash=new TrieNode[26];\n            this.isWord=false;\n        }\n        public StringBuilder dfs(StringBuilder res){\n             \n            StringBuilder max=new StringBuilder();\n            for(int i=0;i<26;i++){\n                if(hash[i]!=null && hash[i].isWord){\n                    StringBuilder temp=new StringBuilder();\n                    temp.append(hash[i].val);\n                    temp.append(hash[i].dfs(temp));\n                    if(temp.length() > max.length())\n                        max=temp;\n                }\n            }\n            return max;\n        }\n        \n    }\n    public String longestWord(String[] words) {\n        TrieNode root=new TrieNode();\n        for(String word:words){\n            TrieNode curr=root;\n            for(int i=0;i<word.length();i++){\n                if(curr.hash[word.charAt(i)-'a']==null){\n                    TrieNode temp=new TrieNode(word.charAt(i));\n                    curr.hash[word.charAt(i)-'a']=temp;\n                }\n                curr=curr.hash[word.charAt(i)-'a'];\n                if(i==word.length()-1)\n                    curr.isWord=true;                    \n            }\n        }\n        StringBuilder res=new StringBuilder();\n        res=root.dfs(res);\n        \n        return res.toString();\n    }\n}\n```
[]