Practice: Python problems
Practice tracks: PySpark & SQL (84) · dbt (25) · Airflow (10) · Python (52)
52 Python interview problems for data engineers: comprehensions, dicts, decorators, generators, classes and DSA, graded in real CPython on hidden tests.
Core Python & data structures
comprehensions, dicts, Counter, defaultdict, deque, sorting and the mutability gotchas.
- Flatten a Nested List · Easy
- Squares of the Even Numbers · Easy
- Top K Frequent Words · Easy
- Invert a Dictionary · Easy
- Merge Dicts and Sum Shared Keys · Easy
- Group Records by Key · Easy
- Count Words in Reviews · Easy
- Zip Columns into Records · Easy
- Find the Missing IDs · Easy
- Safe Min and Max · Easy
- Sort by Several Keys · Medium
- Fix the Mutable Default Argument · Medium
- Override a Config Without Changing It · Medium
- Keep the Last N Events · Medium
Functions & decorators
closures, nonlocal, *args and **kwargs, decorators, functools.wraps and decorator factories.
- Counter with a Closure · Easy
- A Logging Decorator That Keeps Metadata · Easy
- Memoize a Function · Medium
- Time Every Call · Medium
- Retry with Backoff · Hard
- Rate Limiter Decorator · Hard
Generators & iterators
yield, yield from, lazy pipelines, itertools and the iterator protocol.
- Read a File in Chunks · Easy
- Batch an Iterable · Easy
- A Generator Pipeline · Medium
- Moving Average over a Stream · Medium
- Flatten Any Iterable Lazily · Medium
- A Re-iterable Date Range · Medium
- Merge Sorted Streams Lazily · Hard
OOP & classes
properties, dataclasses, abstract base classes, dunder methods and context managers.
- Bank Account with Validation · Easy
- Temperature with Properties · Easy
- Build Records from CSV Rows · Medium
- An Abstract Connector Class · Medium
- A Comparable Version Class · Medium
- LRU Cache · Hard
- A Transaction Context Manager · Hard
Data wrangling
parsing logs, flattening JSON, deduplication, joins, sessionization and schema validation in plain Python.
- Parse Log Lines into Records · Easy
- Reformat Date Strings · Easy
- CSV Rows to Typed Records · Easy
- Flatten Nested JSON · Medium
- Keep the Latest Record per Key · Medium
- Group and Aggregate without pandas · Medium
- Left Join Two Lists of Dicts · Medium
- Merge Overlapping Sessions · Hard
- Schema Validation with a Dead-Letter Queue · Hard
DSA for data engineers
hash maps, stacks, sliding windows, heaps, binary search, k-way merges and topological sort.
- Two Sum · Easy
- Valid Brackets · Easy
- First Non-Repeating Character · Easy
- Group Anagrams · Medium
- Longest Substring Without Repeats · Medium
- Top K Frequent with a Heap · Medium
- Latest Event at or Before a Time · Medium
- Merge K Sorted Linked Lists · Hard
- Task Order with Cycle Detection · Hard