Find the Commit That Broke the Build Using Bisection

Last updated: November 29, 2026

Quick Overview

Given an ordered list of commits where the oldest is known good and the newest is known bad, find the first bad commit with as few test runs as possible. The test is slightly flaky, so a single run can lie.

Microsoft
Software Engineering Fundamentals
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Given an ordered list of commits where the oldest is known good and the newest is known bad, find the first bad commit with as few test runs as possible. The test is slightly flaky, so a single run can lie.

Debugging large codebases like Windows or Office often means finding which of hundreds of commits caused a regression. The interviewer checks that the candidate maps the problem to binary search with a clear invariant, and thinks about flaky tests, which are a real cost in large Microsoft build pipelines.

What the Interviewer Expects
  • States the invariant: lo is good, hi is bad
  • Uses binary search for O(log n) test runs
  • Handles flaky results with repeated runs and a majority vote
  • Explains the assumption that bad stays bad after it first appears
  • Mentions git bisect as the real tool
Key Topics to Cover
binary search
debugging
git bisect
flaky tests
regression hunting
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • What if the build is broken for an unrelated reason in the middle of the range?
  • How would you bisect when the bug was introduced, fixed, then reintroduced?
  • How would you choose the number of runs per probe given a known flake rate?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • commits[0] is good, commits[-1] is bad, and once a commit is bad all later ones are bad (monotonic).
  • is_bad(commit) builds and runs the test; it is expensive and occasionally gives the wrong...
High-Level Design

Binary search over indices with the invariant lo is good and hi is bad. Probe the middle: if bad, move hi there; otherwise move lo. Stop when they are adjacent: hi is the first bad commi...


Submit Your Answer
Markdown supported