O(M * N) algorithm using hash, without sort()
Assign a prime number for a to z, and then multiply all prime numbers together to form a hash value.\n\n\n        \n        private static final int[] PRIMES = 
Assign a prime number for a to z, and then multiply all prime numbers together to form a hash value.\n\n\n        \n        private static final int[] PRIMES = new int[]{2, 3, 5, 7, 11 ,13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 107};\n        \n        public List<String> anagrams(String[] strs) {\n            List<String> list = new LinkedList<>();\n            Map<Integer, List<String>> mapString = new HashMap<>();\n            int result = -1;\n            for (int i = 0; i < strs.length; i++){\n                int mapping = 1;\n                for (int j = 0, max = strs[i].length(); j < max; j++) {\n                    mapping *= PRIMES[strs[i].charAt(j) - 'a'];\n                }\n                List<String> strings = mapString.get(mapping);\n                if (strings == null) {\n                    strings = new LinkedList<>();\n                    mapString.put(mapping, strings);\n                }\n                strings.add(strs[i]);\n            }\n            for (List<String> mapList : mapString.values()){\n                if (mapList.size() > 1)\n                    list.addAll(mapList);\n            }\n            return list;\n        }
['Java']