InterviewStack.io LogoInterviewStack.io

Programming Fundamentals and Code Quality Questions

Encompasses core programming skills, data structures, basic algorithms, language fundamentals, and code quality practices. Expect proficiency with arrays, strings, lists, hash maps or dictionaries, sets, common collection operations, basic sorting and searching algorithms, and tradeoffs between data structures. Understand control flow, functions and modular design, classes and object oriented programming concepts including encapsulation, inheritance, and polymorphism, exception handling, file input and output, and common language idioms for mainstream interview languages such as Python, Java, and C plus plus. Emphasizes writing clean, readable, maintainable code: meaningful naming, modular functions, small interfaces, handling edge cases and errors, logging and documentation, simple testing and debugging strategies, and awareness of time and space complexity for common operations. Candidates should be able to implement correct solutions, follow language specific idioms where appropriate, and demonstrate attention to code quality and readability.

EasyTechnical
34 practiced
Write a Python function `stream_json_lines(path)` that yields one dict per line from a JSON Lines (.jsonl) file without loading the whole file. Handle malformed JSON lines by logging and skipping them, and ensure the file is always closed properly even on exceptions.
MediumTechnical
31 practiced
Write a Python function `top_k_stream(iterable, k)` that returns the k largest elements from an iterator that may be too large to fit in memory. Use O(k) additional memory and O(n log k) time. Explain handling of duplicates and how to return elements in sorted order if required.
HardTechnical
25 practiced
Implement a deterministic random sampler in Python that supports sharding across W workers and K samples per epoch per worker. Given a global seed and epoch number the sampler must produce disjoint deterministic subsets for each worker even when dataset size is not divisible by W. Explain your seeding and mapping approach.
EasyTechnical
31 practiced
Explain the difference between shallow and deep copying in Python. Describe how assignment differs from copying, how `copy.copy` and `copy.deepcopy` behave, and give examples of subtle bugs that arise in ML pipelines when shallow copies of lists of numpy arrays are used.
MediumTechnical
28 practiced
You have a multithreaded Python data loader where worker threads append preprocessed batches to a shared list without synchronization. Identify potential race conditions and propose fixes. Discuss the effect of the Python GIL on this design and recommend alternatives for CPU-bound preprocessing.

Unlock Full Question Bank

Get access to hundreds of Programming Fundamentals and Code Quality interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.