Bisect to the First Bad Commit With a Flaky Test
Last updated: November 29, 2026
Quick Overview
Given an ordered list of commits where the first is good and the last is bad, find the first commit that introduced a failure, when a bad commit fails the test only some of the time.
0
0
0 solved
Given an ordered list of commits where the first is good and the last is bad, find the first commit that introduced a failure, when a bad commit fails the test only some of the time.
Google's monorepo moves fast, and culprit finding for regressions is routine, often with tests that fail intermittently. Interviewers check binary search invariants and probabilistic reasoning about how many reruns make a pass trustworthy.
What the Interviewer Expects
- Maintains a clear lo-good, hi-bad invariant
- Recognizes that a single pass is weak evidence
- Chooses reruns based on failure probability
- Quantifies the chance of a wrong answer
- Discusses when bisection assumptions break
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- If the failure rate is 10%, how many runs do you need for 99% confidence per step?
- What if the test is flaky on good commits too?
- How do you bisect when some commits do not build?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
commits[0]is good,commits[-1]is bad. Good commits always pass. Bad commits fail with some probability p per run.- Return the first bad commit with high confidence, minimizing test runs....
High-Level Design
Binary search with invariant: lo is good and hi is bad. A failure is conclusive evidence of bad since good commits never fail. A pass is not conclusive, so a commit counts as good only if it passe...