Javascript solution using just a hash.
\n/**\n * @param {string[]} words\n * @return {string}\n */\nvar longestWord = function(words) {\n    words.sort((a, b) => a.length - b.length);\n    let i = 0;
```\n/**\n * @param {string[]} words\n * @return {string}\n */\nvar longestWord = function(words) {\n    words.sort((a, b) => a.length - b.length);\n    let i = 0;\n    let hash = {};\n    let longest = \'\'\n    while(i < words.length) {\n        if (words[i].length == 1) {\n            hash[words[i]] = true;\n            if (longest.length == 0 || words[i].localeCompare(longest) < 0) {\n                longest = words[i];\n            }\n        } else {\n            let prevWord = words[i].substring(0, words[i].length - 1)\n            if (hash[prevWord]) {\n                if (words[i].length > longest.length || (words[i].length == longest.length && words[i].localeCompare(longest) < 0))\n                    longest = words[i];\n                hash[words[i]] = true\n            }\n        }\n        i++;\n    }\n    return longest\n};\n```
[]