哈哈
C++ 代码
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
vector<vector<string>> res;
unordered_map<string,vector<string>> data;
for(int i=0;i<strs.size();i++){
string str=strs[i];
sort(str.begin(),str.end());
data[str].push_back(strs[i]);
}
for(const auto& it:data){
res.push_back(it.second);
}
return res;
}
};