1 / 8

DSA ยท Arrays & hashing

Define what makes two items equivalent

Grouping starts with a question: which differences should be ignored? For anagrams, letter order does not matter, but letter counts do. A canonical key gives every equivalent item the same representation.

For lowercase English words, sorting the letters creates such a key: "tea" and "eat" both become "aet".