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
26 practiced
You have a pure-Python feature extraction pipeline (tokenization, regex features, numeric transforms) that is too slow for production. Propose and implement concrete optimizations: batching, vectorization, memoization, and using native libraries. Provide a benchmark harness and show measurable throughput improvements.
HardTechnical
45 practiced
Implement a persistent (immutable) singly-linked list in Python where operations like prepend return a new list sharing structure with previous versions. Provide an API for Cons and Nil, methods to convert to a Python list, and explain complexity for prepend, head, tail, and append operations.
HardTechnical
25 practiced
Implement sparse_matrix_multiply(A_coo, B_coo) in Python where A_coo and B_coo are lists of (i, j, val) tuples representing sparse matrices in COO format. Return the product in COO format efficiently by exploiting sparsity. Discuss time complexity relative to number of non-zeros and memory considerations.
MediumTechnical
23 practiced
Write a pragmatic Python regular expression that matches most common email addresses for validation purposes. Explain why full RFC-compliant email validation via regex is impractical and propose pragmatic validation steps (regex + DNS or SMTP checks). Provide example regex and discuss edge cases such as internationalized domains.
MediumTechnical
30 practiced
Explain the Python Global Interpreter Lock (GIL) and its impact on CPU-bound vs IO-bound workloads. For a data scientist running heavy numpy computations and some Python preprocessing, how would you parallelize tasks effectively? Compare threading, multiprocessing, asyncio, and native C extensions in terms of overhead and suitability.

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.