var groupAnagrams = function(strs) {
let hashmap = new Map()
for(let index = 0;index < strs.length;index++){
let str = strs[index].split('').sort().join();
if(hashmap.has(str)){
let temp = hashmap.get(str)
temp.push(strs[index]);
hashmap.set(str,temp)
}else{
hashmap.set(str,[strs[index]])
}
}
return [...hashmap.values()]
};
重新复习了下map
has 是否包含key
get 获取key对应的value
set(key,value)
[...map.values()] 打印所有的value值