0Pricing
Competitive Programming Academy · Lesson

Group and Bucket with a Map

Group anagrams and similar items.

Grouping Is a Pattern

Many problems ask you to group items that share something. A map from key to bucket turns that into a single clean pass. 🗂️

Pick the Grouping Key

The whole trick is choosing a key that is identical for items in the same group. Get this right and the rest is easy.

All lessons in this course

  1. Sets for Membership and Dedup
  2. Dictionaries as Lookup Tables
  3. Counter and defaultdict in Action
  4. Group and Bucket with a Map
← Back to Competitive Programming Academy