@@ -0,0 +1,1168 @@
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Apublic class LeetCode0049 %7B%0A%09public List%3CList%3CString%3E%3E groupAnagrams(String%5B%5D strs) %7B%0A%0A%09%09List%3CList%3CString%3E%3E result = new ArrayList%3CList%3CString%3E%3E();%0A%0A%09%09if (strs == null %7C%7C strs.length == 0) %7B%0A%09%09%09return result;%0A%09%09%7D%0A%0A%09%09Map%3CString, List%3CString%3E%3E map = new HashMap%3CString, List%3CString%3E%3E();%0A%0A%09%09for (int i = 0; i %3C strs.length; i++) %7B%0A%09%09%09String str = strs%5Bi%5D;%0A%09%09%09String array%5B%5D = str.split(%22%22);%0A%09%09%09Arrays.sort(array);%0A%09%09%09String hash = Arrays.toString(array);%0A%09%09%09if (map.containsKey(hash)) %7B%0A%09%09%09%09map.get(hash).add(str);%0A%09%09%09%7D else %7B%0A%09%09%09%09map.put(hash, new ArrayList%3CString%3E());%0A%09%09%09%09map.get(hash).add(str);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09result.addAll(map.values());%0A%09%09return result;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09LeetCode0049 leetcode = new LeetCode0049();%0A%09%09List%3CList%3CString%3E%3E result = leetcode.groupAnagrams(new String%5B%5D %7B %22eat%22, %22tea%22, %22tan%22, %22ate%22, %22nat%22, %22bat%22 %7D);%0A%09%09for (int i = 0; i %3C result.size(); i++) %7B%0A%09%09%09for (int j = 0; j %3C result.get(i).size(); j++) %7B%0A%09%09%09%09System.out.print(result.get(i).get(j) + %22 %22);%0A%09%09%09%7D%0A%09%09%09System.out.println();%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add LeetCode0049.java