Easy Java Solution || HashMap || Sorting
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String longestWord(String[] arr) {\n        Arrays.sort(arr);\n        HashSet<String> hp = new HashSet<>();\n\n        String ans = "";\n        for(int i=0; i<arr.length; i++){\n            String s = arr[i];\n            if(s.length()==1 || hp.contains(s.substring(0,s.length()-1))){\n                if(s.length()>ans.length()){\n                    ans = s;\n                }\n                hp.add(s);\n            }\n        }\n        return ans;\n    }\n}\n```
['Java']