Day 6 of 30-Day LeetCode Challenge

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;




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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store