InterviewStack.io LogoInterviewStack.io

Python Coding and Data Structures Questions

Proficiency in Python, including arrays, dictionaries, linked lists, and basic algorithms. Ability to write efficient, clean code under time pressure. Understanding of time/space complexity and optimization.

HardTechnical
45 practiced
Implement a thread-safe bounded FIFO queue in Python without using queue.Queue. Use threading primitives (Lock, Condition) to implement put(item) and get() with blocking behavior when full/empty. Explain how this pattern is useful in producer-consumer data-loaders for training.
EasyTechnical
44 practiced
Explain the difference between Python 3 bytes and str. When reading data files for ML (text logs, CSV, JSON), what pitfalls exist with encodings and how would you robustly read files that may contain mixed encodings? Mention defaults and common flags in open() and possible preprocessing steps.
HardTechnical
29 practiced
Implement a consistent hashing ring in Python for distributing keys to N nodes with minimal remapping when nodes are added/removed. Support virtual nodes for balancing. Provide code for add_node(node_id), remove_node(node_id), and get_node(key). Explain time complexity and how you'd use this to shard a feature store or embedding cache.
HardTechnical
23 practiced
Design a memory-efficient serialization scheme in Python for storing very large NumPy arrays with metadata and streaming writes (so you don't hold the entire array in RAM). Provide example code that writes chunks to disk and reads them back with minimal memory overhead (mention numpy.memmap, HDF5/h5py or Apache Arrow). Discuss pros/cons for ML checkpoints and input datasets.
EasyTechnical
25 practiced
Explain how Python's dict is implemented under the hood (high level). Discuss collision handling, resizing behavior, average and worst-case complexities for lookup/insert/delete, and how these behaviors affect using dicts for large feature hashing, caches, or embedding lookups in ML pipelines.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.