标签:str 分组 ring auto nbsp code map tor cto
1 class Solution 2 { 3 public: 4 vector<vector<string>> groupAnagrams(vector<string>& strs) 5 { 6 vector<vector<string>> res; 7 unordered_map<string,vector<string>> hash; 8 for(auto a : strs) 9 { 10 string temp = a; 11 sort(temp.begin(),temp.end()); 12 hash[temp].push_back(a); 13 } 14 for(auto h : hash) 15 { 16 res.push_back(h.second); 17 } 18 return res; 19 } 20 };
标签:str 分组 ring auto nbsp code map tor cto
原文地址:https://www.cnblogs.com/yuhong1103/p/12519156.html