class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
List<List<String>> result = new LinkedList<>();
Map<String, List<String>> map = new HashMap<>();
for(String str : strs){
char[] chars = str.toCharArray();
Arrays.sort(chars);
String key = String.valueOf(chars);
if(map.containsKey(key)){
List<String> temp = map.get(charToStr);
temp.add(str);
map.put(key, temp);
}else{
List<String> temp = new LinkedList<>();
temp.add(str);
map.put(key, temp);
}
}
for(List<String> value : map.values()){
result.add(value);
}
return result;
}
}
if(!map.containsKey(key)) map.put(key, new LinkedList<>());
map.get(key).add(str);
return new LinkedList<>(map.values());
String.valueOf(array)
char 배열을 String 문자형으로 변환