There was an error while loading. Please reload this page.
1 parent ded6612 commit 9d551b4Copy full SHA for 9d551b4
08 August Leetcode Challenge 2021/12_groupAnagrams.cpp
@@ -0,0 +1,18 @@
1
+class Solution {
2
+public:
3
+ vector<vector<string>> groupAnagrams(vector<string>& strs) {
4
+ unordered_map<string, vector<string>> mp;
5
+ for(auto i: strs){
6
+ string temp = i;
7
+ sort(temp.begin(), temp.end());
8
+ mp[temp].push_back(i);
9
+ }
10
+
11
+ vector<vector<string>> res;
12
+ for(auto i: mp){
13
+ res.push_back(i.second);
14
15
16
+ return res;
17
18
+};
0 commit comments