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
31 practiced
Implement a simple mark-and-sweep garbage collector simulation in Python. Represent objects and their references with a dict of id -> list_of_child_ids, implement the mark phase from given roots, then sweep unreachable objects. Explain how this differs from reference counting and provide complexity analysis.
HardTechnical
31 practiced
Design an efficient Python approach to detect schema anomalies across millions of JSON documents representing event records. Your solution should stream documents, aggregate observed types per field path, and report fields with type changes, missingness, or structural drift. Provide prototype code and discuss accuracy versus sampling trade-offs.
MediumTechnical
23 practiced
Implement serialize(root) and deserialize(data) functions in Python for binary trees with integer node values. Use preorder traversal with explicit null markers or level-order encoding. Ensure the format handles negative numbers and duplicates and is compact and reversible.
HardTechnical
32 practiced
Design and implement a RandomizedSet class in Python supporting insert(val), remove(val), and get_random() in average O(1) time. Ensure get_random returns a uniformly random element among current elements. Discuss how you would extend this to support duplicates and weighted sampling.
MediumTechnical
29 practiced
You must compute sum(value) grouped by user_id from a CSV file too large to fit in memory. Using only Python standard libraries, write a streaming approach that produces aggregated sums per user with bounded memory footprint, or explain when external aggregation (partition + reduce) is required. Provide code sketch and complexity analysis.

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.