class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
vector<vector<string>> res;
map <string,vector<string> > m;
for(string& s : strs){
string t = s;
sort(t.begin(),t.end());
m[t].push_back(s);
}
for(auto& ch : m){
res.push_back(ch.second);
}
return res;
}
};
11-17
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交