import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LeetCode0049 {
	public List<List<String>> groupAnagrams(String[] strs) {

		List<List<String>> result = new ArrayList<List<String>>();

		if (strs == null || strs.length == 0) {
			return result;
		}

		Map<String, List<String>> map = new HashMap<String, List<String>>();

		for (int i = 0; i < strs.length; i++) {
			String str = strs[i];
			String array[] = str.split("");
			Arrays.sort(array);
			String hash = Arrays.toString(array);
			if (map.containsKey(hash)) {
				map.get(hash).add(str);
			} else {
				map.put(hash, new ArrayList<String>());
				map.get(hash).add(str);
			}
		}
		result.addAll(map.values());
		return result;
	}

	public static void main(String[] args) {
		LeetCode0049 leetcode = new LeetCode0049();
		List<List<String>> result = leetcode.groupAnagrams(new String[] { "eat", "tea", "tan", "ate", "nat", "bat" });
		for (int i = 0; i < result.size(); i++) {
			for (int j = 0; j < result.get(i).size(); j++) {
				System.out.print(result.get(i).get(j) + " ");
			}
			System.out.println();
		}
	}
}

@@ -474,22 +474,20 @@
 %5Bi%5D;%0A%09%09%09
-String
+char
  array%5B%5D
@@ -497,16 +497,20 @@
 str.
-split(%22%22
+toCharArray(
 );%0A%09
@@ -552,23 +552,22 @@
 h = 
-Arrays.toString
+String.valueOf
 (arr
@@ -1161,9 +1161,8 @@
 %09%09%7D%0A%09%7D%0A%7D
-%0A

Update LeetCode0049.java