Easy to Understand Java Code
Complexity\n- Time complexity:\nO(nlogn)\n- Space complexity:\nO(n)\n# Code\n\nclass Solution {\n    public String longestWord(String[] words) {\n        Arrays
# Complexity\n- Time complexity:\nO(nlogn)\n- Space complexity:\nO(n)\n# Code\n```\nclass Solution {\n    public String longestWord(String[] words) {\n        Arrays.sort(words);\n        HashSet<String> set = new HashSet();\n        String result = "";\n\n        for(String w : words){\n            if(w.length() == 1 || set.contains(w.substring(0, w.length()-1))){\n                if(w.length() > result.length()) result = w;\n                set.add(w);\n            }\n        }\n\n        return result;\n    }\n}\n```
['Array', 'Hash Table', 'String', 'Sorting', 'Java']