Group Anagrams

Read the lesson → understand the pattern → then code. Tutor works offline (built-in teacher); optional Cursor/Gemini keys upgrade chat quality.

Topic refresher: Hashing — Pay Space, Buy Time

Replace nested loops with unordered_map / unordered_set lookups.

unordered_map<int,int> mp;
for (int i = 0; i < n; i++) {
    int need = target - nums[i];
    if (mp.count(need)) return {mp[need], i};
    mp[nums[i]] = i;
}
Hashing

Group Anagrams

Medium
LeetCode
3/8
MediumHashingLeetCode #49

Group Anagrams

Key = sorted string (or 26-count signature). Map key → list of words.

Examples

Example 1

Input

6
eat tea tan ate nat bat

Output

ate eat tea | bat | nat tan

Stuck? Take a nudge

C++17