C++ | Optimized O(nk) | without sorting | map of map technique
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nmap of map technique. m
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nmap of map technique. map inside map. the inner map should be of size 26.  (O(nk))\n\n`map<map<char,int>,vector<string>> mp`\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nk)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<string>> groupAnagrams(vector<string>& strs) {\n\n        vector<vector<string>> ans;\n\n        map<map<char,int>, vector<string>> mp;\n        int n = strs.size();\n        string temp;\n        \n        for(int i=0;i<n;i++)\n        {\n            map<char,int> temp;\n            for(char c:strs[i]){\n                temp[c]++;\n            }\n\n            mp[temp].push_back(strs[i]);\n        }\n\n\n        for(auto itr=mp.begin();itr!=mp.end();itr++)\n        {\n            ans.push_back(itr->second);\n        }\n\n        return ans;\n\n\n        \n    }\n};\n```
['C', 'Python', 'C++', 'Java', 'Python3']