Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. class Solution { public: vector<string> anagrams(vector<string> &strs) { vector<string> res; map<string, vector<string>> mp; for(const auto &s : strs) { string key(s); sort(key.begin(), key.end()); mp[key].push_back(s); } for(auto it = mp.begin(); it != mp.end(); ++it) { if(it->second.size() > 1) res.insert(res.end(), it->second.begin(), it->second.end()); } return res; } };