Group Anagrams Time : O(n) Space : O(n) 12345678910111213141516#include <vector>using namespace std;vector<vector<string>> groupAnagrams(vector<string> words) { unordered_map<string, vector<string>> mp; for(auto& w : words) { string s = w; sort(begin(s), end(s)); mp[s].push_back(w); } vector<vector<string>> res; for(auto& [_, g] : mp) res.push_back(g); return res;}