Untitled
unknown
plain_text
a year ago
424 B
4
Indexable
class Solution { public: vector<vector<string>> groupAnagrams(vector<string>& strs) { vector<vector<string>>res; if(strs.empty()) return res; unordered_map<string,vector<string>> mp; for(auto i:strs){ string wrd=i; sort(wrd.begin(),wrd.end()); mp[wrd].push_back(i); } for(auto i:mp) res.push_back(i.second); return res; } };
Editor is loading...
Leave a Comment