ArrayList<String> longestWords(String[] dictionary) {
        // write your code here
        int max = 0;
        HashMap<Integer, ArrayList<String>> map = new HashMap<Integer, ArrayList<String>>();
        for (String str : dictionary) {
            int len = str.length();
            if (len > max) {
                ArrayList<String> ans = new ArrayList<String>();
                ans.add(str);
                map.put(len, ans);
                max = len;
            } else if (len == max) {
                map.get(len).add(str);
            }
        }
        return map.get(max);
    }