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
Compare storing dense numeric features as Python list-of-lists, numpy.ndarray, and array.array for use in model training pipelines. For each representation describe memory layout, typical memory footprint, speed for iteration and vectorized ops, slicing behavior, pickling/serialization characteristics, and interop with C extensions.
HardTechnical
0 practiced
Implement a Python generator that streams the intersection of two very large sorted files on disk (each line is a sorted integer) and yields common elements with minimal memory. Explain your buffering approach, how you avoid loading whole files, and how to skip efficiently (binary-search/seek) if one file is much larger than the other.
HardTechnical
0 practiced
Design and implement in Python an approximate distinct-count estimator using HyperLogLog to count unique user IDs in a stream. Explain register width/precision, how to hash inputs into registers, merge sketches across shards, and expected error characteristics versus exact counting.
MediumTechnical
0 practiced
Write a Python function rotate_right(nums: List[int], k: int) that rotates the list to the right by k positions in-place with O(n) time and O(1) extra space. Do not use extra lists or collections.deque.rotate. Explain why the three-reverse technique works and handle edge cases like k >= len(nums) or empty list.
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.