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.
Values that appear once
Return a list of numbers that appear exactly once in the input list, in original order.
Sort by frequency
Sort a list by element frequency descending, with ties broken by order of first occurrence.
Pair with difference K
Count unordered index pairs with absolute difference exactly K, handling duplicates correctly.
Frequency sort descending
Write a function that sorts a list by frequency descending while preserving original order for ties.
Function composition
Return a function that applies f after g: compose(f, g)(x) == f(g(x)).
Dataclass with slots
Implement a slotted frozen dataclass representing a 2D point with total ordering.
Valid parentheses
Return True if brackets in the string close in the correct order.
BFS level-order traversal
Return the level-order traversal of a binary tree as a list of lists.
LRU cache decorator
Implement @lru_cache(maxsize=N) for unary functions using OrderedDict.
Topological sort (Kahn)
Return a valid topological ordering of tasks, or [] if a cycle exists.
Count pairs with given difference
Count how many unordered pairs in a list have a given absolute difference using an efficient approach.
Bubble Sort
Implement bubble sort that sorts a list of numbers in ascending order.
Selection Sort Implementation
Implement selection sort to sort a list of numbers in ascending order.
Heap Sort Implementation
Implement the heap sort algorithm to sort a list of comparable elements in non-decreasing order.
Radix Sort
Implement LSD radix sort to sort a list of non-negative integers in ascending order.
Reconstruct Itinerary
Given a list of airline tickets, reconstruct the itinerary in order using each ticket exactly once, choosing the lexicographically smallest path when multiple options exist.
AST Visitor Lite
Implement a depth-first traversal of a simplified AST and return identifier names in order.
Argsort Indices
Implement a function that returns the indices that would sort a list of integers, with ties broken by original order.
Level Order Traversal
Implement a function that performs a level order traversal of a binary tree and returns node values as a list of lists.
Strobogrammatic number II
Given a positive integer n, return all strobogrammatic numbers of length n in ascending order.
Tree inorder generator
Write a generator function that yields a binary tree's node values in inorder traversal.
Flatten Nested List Iterator
Implement a class that iterates over all integers in a nested list structure in depth-first order.
Showing 25–48 of 78 challenges
Guide: free Python coding challenges
Practice Python by solving problems
PythonSkillset challenges are hands-on coding exercises from beginner to advanced. Open a challenge, read the problem, write Python in the split-pane editor, and run tests with Pyodide — no install required.
How to use the arena
- Pick a category — basics, algorithms, strings, and more
- Open a challenge, read the statement, and edit the starter code
- Run tests, fix failures, then try a related quiz or tutorial lesson
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.