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.

HardTechnical
0 practiced
Implement a Count-Min Sketch in Python to estimate frequencies on a high-cardinality stream. The API should support initialization with epsilon/delta or width/depth, update(key, count=1) and estimate(key). Use salted hash functions (via hashlib) and discuss error bounds, memory/time complexity, and how to merge two sketches.
HardTechnical
0 practiced
Given a stream of (user_id, item_id) interactions, design a Python solution to compute top-K popular items per user in a streaming, memory-constrained environment where there may be millions of users. Provide code ideas (per-user min-heaps, on-disk spill, sharding) and discuss scaling/sharding strategies and eviction policies for cold users.
MediumTechnical
0 practiced
Using collections.defaultdict, implement a streaming aggregator that computes count, sum, min, max, and mean per key from an iterator of (key, value) pairs without storing per-key lists. Provide code and explain any numerical stability concerns and how to compute variance online if needed.
MediumTechnical
0 practiced
Explain how Python's built-in sort (Timsort) works at a high level. Describe its best/average/worst-case time complexities, stability, how it exploits existing order (runs), and why its stability matters for ML preprocessing (e.g., stable feature ordering).
MediumTechnical
0 practiced
You're implementing a feature: count events in the last hour per user. For each user you maintain a sorted list of event timestamps. Using Python's bisect module, write code to count events inside a sliding 1-hour window when a new event arrives, and discuss insertion and query complexity. Suggest alternate data structures if updates are very frequent.

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.