public List<String> anagrams(String[] strs) {
        if (strs == null)
            return result;
        for (int i = 0; i < strs.length; i++) {
            if (map.containsKey(toSort(strs[i]))
                    && count.get(toSort(strs[i])) == 0) {
                result.add(map.get(toSort(strs[i])));
                result.add(strs[i]);
                count.put(toSort(strs[i]), 1);
            } else if (map.containsKey(toSort(strs[i]))) {
                result.add(strs[i]);
            } else {
                map.put(toSort(strs[i]), strs[i]);
                count.put(toSort(strs[i]), 0);
            }
        }
        return result;
    }