Javascript solutions: Set beats 97% | Trie beats 66%
\n/**\n * @param {string[]} words\n * @return {string}\n */\nvar longestWord = function(words) {\n    if (!words.length) return \'\'\n    words.sort()\n    let 
```\n/**\n * @param {string[]} words\n * @return {string}\n */\nvar longestWord = function(words) {\n    if (!words.length) return \'\'\n    words.sort()\n    let set = new Set()\n    let ans = \'\'\n    for (let i = 0; i < words.length; i++) {\n        let prev = words[i].substring(0, words[i].length - 1)\n        if (words[i].length === 1 || set.has(prev)) {\n          ans = words[i].length > ans.length ? words[i] : ans\n          set.add(words[i])\n        }\n    }\n    return ans\n};\n\n/**\n * @param {string[]} words\n * @return {string}\n */\nvar longestWord = function(words) {\n    let trie = new Trie()\n    for (let i = 0; i < words.length; i++) {\n      trie.add(words[i])\n    }\n    let longestWord = \'\'\n    var dfs = function(node, s) {\n      let keys = Object.keys(node.storage)\n      for (let i = 0; i < keys.length; i++) {\n        if (node.storage[keys[i]].isWord) {\n          dfs(node.storage[keys[i]], s + keys[i])\n        }\n      }\n      if (s.length > longestWord.length) {\n        longestWord = s\n      } else if (s.length === longestWord.length) {\n        longestWord = getSmallest(s, longestWord)\n      }\n    }\n    dfs(trie.root, \'\')\n    return longestWord\n};\n\nvar getSmallest = function(a, b) {\n    for (let i = 0; i < a.length; i++) {\n        if (a[i] < b[i]) {\n            return a\n        } else if (b[i] < a[i]) {\n            return b\n        }\n    }\n    return a\n}\n\nclass Node {\n    constructor() {\n        this.isWord = false\n        this.storage = {}\n    }\n}\n\nclass Trie {\n    constructor() {\n        this.root = new Node()\n    }\n    add(word) {\n        let curr = this.root\n        for (let i = 0; i < word.length; i++) {\n            if (!curr.storage[word[i]]) {\n                curr.storage[word[i]] = new Node()\n            }\n            curr = curr.storage[word[i]]\n        }\n        curr.isWord = true\n    }\n}\n```
['Trie', 'Ordered Set', 'JavaScript']