InterviewStack.io LogoInterviewStack.io

Python Data Structures and Algorithms Questions

Core Python data structure and algorithm knowledge used for manipulating collections and solving common data processing problems. Candidates should know built in types such as lists, dictionaries, sets, and tuples and their performance characteristics; be able to implement and reason about searching, sorting, counting, deduplication, and frequency analysis tasks; and choose appropriate algorithms and data structures for time and space efficiency. Familiarity with Python standard library utilities such as collections.Counter, defaultdict, deque, and heapq is expected, as is writing Pythonic, clear code that handles edge cases. Questions may include algorithmic trade offs, complexity analysis, and applying these techniques to practical data manipulation problems where custom logic is required beyond what pandas or NumPy provide.

HardSystem Design
16 practiced
Design a distributed LRU caching strategy for a fleet of Python data-processing workers where each worker has a local in-memory cache and Redis is available as a shared store. Explain consistency models (eventual vs strong), eviction coordination, cache-aside vs write-through, warm-up/rehydration, and how to minimize cross-worker cache misses and network overhead.
MediumTechnical
22 practiced
You need to generate combinations of 10 features taken 3 at a time for feature engineering but some feature pairs are invalid. Implement a Python generator using itertools.combinations that prunes invalid combinations early and stops after N valid combinations. Provide code and explain how pruning reduces work and memory use.
MediumTechnical
17 practiced
Explain Python's built-in sorted() stability and the properties of Timsort. In a pipeline where you need to sort records by (primary_key, timestamp) and maintain stability, describe an efficient approach that minimizes memory overhead and respects ordering. When is it better to sort once with a composite key vs multiple stable sorts?
EasyTechnical
29 practiced
Compare Python list, tuple, set, and frozenset focusing on mutability, hashability, typical memory footprint, and iteration/lookup speed. For a data-engineering pipeline that stores record keys or partition keys, explain when you would choose a tuple vs a list and when a frozenset or set is the right choice.
MediumTechnical
17 practiced
Implement a lightweight Count-Min Sketch class in Python with methods add(item) and estimate(item) to approximate frequency counts using a w x d array of counters. Explain the error bounds (epsilon, delta) and how to choose width and depth given a memory budget for an online streaming job.

Unlock Full Question Bank

Get access to hundreds of Python Data Structures and Algorithms interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.