publicclassSolution { /** * @param strs: A list of strings * @return: A list of strings */publicList<String> anagrams(String[] strs) {List<String> res =newArrayList<>();Map<String,List<String>> map =newHashMap<>();for (String s : strs) {char[] sArr =s.toCharArray();Arrays.sort(sArr);String sSorted =newString(sArr);map.putIfAbsent(sSorted,newArrayList<String>());map.get(sSorted).add(s); }for (List<String> list :map.values()) {if (list.size() >1)res.addAll(list); }return res; }}