🎉 One-stop destination for all your technical interview Preparation 🎉
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs)
{
vector<vector<string>> res;
unordered_map<string, vector<string>> mp;
for (string& s : strs) {
string t = s;
sort(t.begin(), t.end());
mp[t].push_back(s);
}
for (auto m : mp) {
res.push_back(m.second);
}
return res;
}
};