Are two lists the same multiset
Write a function that checks if two lists contain the same elements with the same multiplicities, ignoring order.
Word to Index Map
Create a function that returns a dictionary mapping each unique word to the index of its first occurrence.
Group names by first letter
Given a list of names, return a dictionary mapping each first letter to all names starting with that letter in original order.
Keys Sorted by Value Descending
Given a dictionary mapping strings to integers, return a list of keys sorted by value descending, and when values tie, alphabetically ascending.
Nested get with dotted path
Implement a function that safely retrieves a value from a deeply nested dictionary using a dot-separated path, returning a default if any key is missing.
Anagram Dictionary Groups Lite
Group a list of words into anagrams using a dictionary keyed by sorted characters.
Top k keys by count
Given a dictionary mapping keys to counts, return the top k keys with the highest counts, breaking ties alphabetically.
Replace keys with a mapping
Write a function that renames keys in a dictionary according to a mapping, with duplicate handling.
Two Sum with Dict
Implement the classic Two Sum problem: return indices of two numbers that add up to a target using a dict.
Top K Frequent Words
Given a list of words, return the k most frequent words sorted by frequency (descending) and then alphabetically.
Pair with difference K
Count unordered index pairs with absolute difference exactly K, handling duplicates correctly.
Count Pairs with Sum
Implement a function that counts the number of distinct pairs in a list summing to a target.
Ransom Note Builder
Given two strings, determine if the ransom note can be formed from the words in the magazine.
Showing 13 challenges · easy · Dicts & Sets
Dicts & Sets — Python coding challenges
What you will find here
This page lists dicts & sets challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.