[C++] Easy, Clean Solution using Sorting and Map
Solution:\n\nApproach\n1. We need to group all anagrams together.\n2. An Anagram is a word or phrase formed by rearranging the letters of a different word or ph
**Solution:**\n\n**Approach**\n1. We need to group all `anagrams` together.\n2. An Anagram is a word or phrase formed by `rearranging the letters` of a different word or phrase, typically using all the original letters `exactly once`.\n3. If we sort a particular string, we have one `unique string` which can be called as the `primary string` through which all anagrams were made(Just an imagination to understand the concept better).\n4. For each sorted string, group it with its anagram(original string) using `map`.\n5. Return the `result` in any order.\n```\nclass Solution {\npublic:\n    vector<vector<string>> groupAnagrams(vector<string>& strs) {\n        unordered_map<string, vector<string>> mp;\n        for(auto i: strs){\n            string temp = i;\n            sort(temp.begin(), temp.end());\n            mp[temp].push_back(i);\n        }\n        \n        vector<vector<string>> res;\n        for(auto i: mp){\n            res.push_back(i.second);\n        }\n        \n        return res;\n    }\n};\n```\n\nTime Complexity: `O(n * (m * log(m)))`\n* where n is the total number of strings present in the `vector` and m is the `maximum length` of a string in the vector. Here, sorting the strings causes `(m * log(m))` addition to the complexity.\n\nSpace Complexity: `O(n * m)`\n\n**Feel free to share your ideas or any improvements as well.**
['String', 'C', 'Sorting']