#include using namespace std; class Solution { public: vector> groupAnagrams(vector &strs) { vector> res; unordered_map> ht; for (const auto &str : strs) { int counts[26] = {0}; for (char c : str) { counts[c - 'a']++; } string key; for (int i : counts) { key.push_back('#'); key.push_back(i + '0'); } ht[key].push_back(str); } for (const auto &t : ht) { res.push_back(t.second); } return res; } };