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
21 practiced
Write Python code to compute MinHash signatures for a list of tokenized documents and then use LSH (banding) to generate candidate pairs for high Jaccard similarity. Provide functions to compute k MinHash values per document and to bucket signatures into bands. Explain parameter choices (k and bands) and trade-offs between false positives and false negatives.
HardTechnical
18 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
23 practiced
Implement a RunningMedian class in Python that supports add(num) and get_median() using two heaps (max-heap for lower half, min-heap for upper half) so that each insertion is O(log n) and retrieving the median is O(1). Provide code and explain handling even/odd counts and negative numbers.
EasyTechnical
22 practiced
Explain the main Python built-in collection types (list, tuple, set, dict) and their typical use-cases in machine-learning data pipelines. For each type, state average-case time complexity for indexing/access, insertion, deletion, membership test, and key hashing where applicable. Mention mutability/immutability, order-preservation guarantees across modern Python versions, and when you'd prefer one over another in production feature-engineering code.
HardTechnical
34 practiced
You need to deduplicate a collection of very large text blobs (each >1MB) stored on disk. Propose and implement in Python a memory- and I/O-efficient approach that minimizes loading full blobs into memory, uses fingerprinting to avoid false positives, and performs a two-pass verification when needed. Provide code sketches and justify design choices.

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.