InterviewStack.io LogoInterviewStack.io

Debugging and Performance Optimization Questions

Finding and fixing what is wrong or slow: systematic debugging strategies, reading stack traces, profiling to locate hotspots, and optimizing execution time and memory. Covers reasoning from symptom to root cause and measuring before optimizing, including runtime, memory, and profiling analysis. Tests how a candidate operates on code they did not write.

EasyTechnical
60 practiced

Given the following Python function, state its time and space complexity and explain why:

def find_duplicates(arr):
seen = set()
dupes = []
for x in arr:
if x in seen:
dupes.append(x)
else:
seen.add(x)
return dupes

Explain edge cases and how complexity changes if arr contains complex or unhashable objects.

MediumTechnical
49 practiced

Implement a Python program that reads a very large file of newline-separated JSON objects and counts occurrences of a specific field value in constant streaming memory. Explain how you would handle malformed JSON lines, performance considerations (buffering, C-based JSON parsers), and fallback strategies if the number of unique values is too large to hold exactly in memory.

MediumTechnical
59 practiced

During a code review you notice a colleague optimized a function for speed but removed unit tests and made the code more complex. How do you approach the review? Which questions do you ask, what trade-offs do you consider, and when would you insist on test coverage, added documentation, or rolling back the change?

HardTechnical
42 practiced

Design an experiment to measure the latency and CPU overhead of adding distributed tracing to a critical API. Describe baseline measurement, sampling strategies (probabilistic vs deterministic), metrics to capture, how to measure overhead in isolation and end-to-end, and what acceptable overhead budget you would set.

MediumTechnical
59 practiced

Describe how to profile a CPU-bound Python application to find hotspots in production with minimal overhead. Compare tools and techniques such as cProfile, py-spy, and sampling profilers; explain when to use each and how to interpret results (including flame graphs).

Unlock Full Question Bank

Get access to all 40 Debugging and Performance Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.