← All problems

Group Anagrams (hashmap drill)

Medium hash mapsstrings LeetCode ↗
Given an array of strings, group anagrams together using hashing rather than pairwise comparison. Design a hashable canonical key for each anagram class.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n*k), Space O(n*k)

Common pitfalls

  • Sorted-key O(k log k) overhead
  • Mutable keys

Your solution

Log in to save your code and track progress.