Sets and Dictionaries Python practice problems
Choose sets for membership and dictionaries for relationships, grouping, and frequency tables.
Core concepts
Problem-solving patterns
- Use a set for membership; use a dictionary for key-to-value state
Reported company tags
All 20 problems in this topic
Work from top to bottom to build the concept gradually.
- #101Calculate set union and intersection: Shared course IDsIntermediatePremium
Compare course IDs selected by two students.
- #102Calculate set union and intersection: Disjoint choicesIntermediatePremium
Handle two groups with no values in common.
- #103Count unique words: Repeated topic wordsIntermediatePremium
Count distinct words in a short, case-insensitive note.
- #104Count unique words: All repeatedIntermediatePremium
Return one when the same word appears with different capitalization.
- #105Build a word-frequency table: Analyze feedbackIntermediatePremium
Count every word in a short feedback line.
- #106Build a word-frequency table: Single vocabulary itemIntermediatePremium
Count a line containing just one repeated word.
- #107Calculate a student's average: Three assessmentsIntermediatePremium
Create a small record and report a learner's average.
- #108Calculate a student's average: Decimal resultsIntermediatePremium
Support assessment scores with decimal values.
- #109Update inventory: Deliveries and salesIntermediatePremium
Apply a sequence of deliveries and sales to current stock.
- #110Update inventory: Prevent negative stockIntermediatePremium
Clamp stock at zero if an outgoing request exceeds availability.
- #111Group anagrams: Several word familiesIntermediatePremium
Group words that contain the same letters.
- #112Group anagrams: No matchesIntermediatePremium
Produce one single-word group for each unrelated word.
- #113Invert a dictionary: Code lookupIntermediatePremium
Reverse a name-to-code mapping so codes become searchable keys.
- #114Invert a dictionary: Numeric-looking valuesIntermediatePremium
Invert text pairs whose values happen to contain digits.
- #115Find the top k frequent values: Top two product codesIntermediatePremium
Find the two most frequent product codes.
- #116Find the top k frequent values: Frequency tieIntermediatePremium
Break equal-frequency ties by choosing smaller values first.
- #117Merge numeric dictionaries: Combine branch salesIntermediatePremium
Add sales totals from two branches by product key.
- #118Merge numeric dictionaries: No shared keysIntermediatePremium
Merge mappings whose keys do not overlap.
- #119Build an adjacency list: Small networkIntermediatePremium
Convert a small undirected network into neighbor lists.
- #120Build an adjacency list: Include an isolated vertexIntermediatePremium
Show an empty adjacency list for a vertex with no edges.