Day 6 of 30-Day LeetCode Challenge

Aanchal Patial
1 min readApr 15, 2020

Given an array of strings, group anagrams together.

class Solution {
vector<vector<string>> groupAnagrams(vector<string>& strs) {
vector<vector<string>> result;

unordered_map<string, vector<string>> mp;

for(int i=0;i<strs.size();++i){ //O(nklogk)

string curr = strs[i];
sort(curr.begin(), curr.end());


for(auto i:mp){
return result;




Aanchal Patial

We never really grow up, we only learn how to act in public