# 题目描述

Given an array of strings, group anagrams together.
For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],
Return:
[
[“ate”, “eat”,”tea”],
[“nat”,”tan”],
[“bat”]
]
Note:
For the return value, each inner list’s elements must follow the lexicographic order.
All inputs will be in lower-case.

# 题目解答

#### 代码实现

public class Solution {
public List<List<String>> groupAnagrams(String[] args) {
if(args == null || args.length == 0)
return null;

HashMap<String, List<String>> map = new HashMap<>();
for(int i = 0; i < args.length; i++){

char[]  c = args[i].toCharArray();
Arrays.sort(c);
String key = String.valueOf(c);
List<String> value = map.get(key);
if(value == null)
value = new ArrayList<>();
map.put(key, value);
}

List<List<String>> ret = new ArrayList<>();
for(String key : map.keySet()){
List<String> temp = map.get(key);
Collections.sort(temp);
}

return ret;
}
}

#### [leetcode] 49. Group Anagrams 解题报告

2016-02-29 05:02:32

#### leetcode：Group Anagrams 【Java】

2016-03-11 14:51:12

#### LeetCode-49-Group Anagrams(哈希)-Medium

2016-01-10 18:32:32

#### leetcode 49. Group Anagrams （Java实现）

2017-01-06 15:47:40

#### LeetCode 49. Group Anagrams （Python）

2017-08-05 19:28:54

#### [LeetCode] Group Anagrams

2015-08-19 11:07:03

#### LeetCode（49）Group Anagrams

2015-09-01 20:28:44

#### LeetCode-49. Group Anagrams (JAVA)按照字典序分组

2017-04-21 13:08:27

#### LeetCode题解：Group Anagrams

2015-09-06 21:24:27

#### Anagrams -- LeetCode

2014-03-21 01:02:04