Data Structures19 sections · 729 units
Open in Course

Lessons from Group Anagrams

Custom hash keys

What did you learn?

1.1. Hash map keys can be complex: strings, tuples, or any hashable type.

2.2. The key should be a "canonical form" that's identical for equivalent items.

3.3. Different canonical forms have different trade-offs. Choose based on your constraints. This pattern appears in: grouping equivalent items, finding duplicates with custom equality, and caching with complex keys.