Simple solution using Trie (No Sorting) | Java
\tclass LongestWordInDictionary {\n    \n\t\t// Time Complexity: O(sum of length of each string in the arr) --> O(sum(len(s)))   (where s -> string in arr)\n\t\
\tclass LongestWordInDictionary {\n    \n\t\t// Time Complexity: O(sum of length of each string in the arr) --> O(sum(len(s)))   (where s -> string in arr)\n\t\t// Space Complexity: O(sum(len(s)))\n    \n\t\tclass TrieNode{\n\t\t\tTrieNode[] children;\n\t\t\tString word;\n\n\t\t\tpublic TrieNode(){\n\t\t\t\tchildren = new TrieNode[26];\n\t\t\t\tword = "";\n\t\t\t}\n\t\t}\n\n\t\tTrieNode root;\n\t\tString result = "";\n    \n\t\tpublic String longestWord(String[] words) {\n\t\t\t// Edge case checking\n\t\t\tif(words == null || words.length == 0)\n\t\t\t\treturn "";\n\n\t\t\troot = new TrieNode();\n\n\t\t\t//insert and build trie dictionary\n\t\t\tinsert(words);\n\n\t\t\t//dfs\n\t\t\tdfs(root);\n\n\t\t\treturn result;\n\t\t}\n    \n\t\tprivate void insert(String[] words){\n\t\t\t// For every word in words - we construct the trie, character by character also keep the track of word at each point\n\t\t\tfor(String s: words){\n\t\t\t\tTrieNode curr = root;\n\t\t\t\tfor(char c : s.toCharArray()){\n\t\t\t\t\tif(curr.children[c - \'a\'] == null)\n\t\t\t\t\t\tcurr.children[c - \'a\'] = new TrieNode();\n\t\t\t\t\tcurr = curr.children[c - \'a\'];\n\t\t\t\t}\n\t\t\t\tcurr.word = s;\n\t\t\t}\n\t\t}\n    \n\t\tprivate void dfs(TrieNode root){\n\t\t\t// If our word length > result length - then update result\n\t\t\tif(root.word.length() > result.length())\n\t\t\t\tresult = root.word;\n\n\t\t\t/// Traverse the nodes of a trie from left to right (a to z) (No need for sorting)\n\t\t\tfor(int i = 0; i < 26; i++){\n\t\t\t\tif(root.children[i] != null && root.children[i].word != "")\n\t\t\t\t\tdfs(root.children[i]);\n\t\t\t}\n\t\t}\n\t}
['Depth-First Search', 'Trie', 'Java']