Locate the First Failing Build in a Deployment Pipeline History
Last updated: November 29, 2026
Quick Overview
Builds are numbered 1 to n, and once a build fails its health checks every later build fails too. Given an is_bad(build) API that is expensive to call, find the first failing build with as few calls as possible.
Amazon
November 29, 20260
0
0 solved
Builds are numbered 1 to n, and once a build fails its health checks every later build fails too. Given an is_bad(build) API that is expensive to call, find the first failing build with as few calls as possible.
A short Amazon phone screen problem framed as bisecting a broken release in a continuous deployment pipeline. The interviewer checks a correct lower-bound binary search and overflow-safe midpoints, and often asks how this mirrors git bisect.
What the Interviewer Expects
- Recognize the monotonic predicate and use binary search
- Write the lower-bound loop with lo < hi and hi = mid
- Compute mid without overflow in fixed-width languages
- Explain O(log n) API calls
- Clarify behavior if no build is bad
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you adapt this if is_bad were flaky and sometimes returned the wrong result?
- What if checking a build took an hour and you could test several in parallel?
- How does git bisect apply the same idea to a commit DAG?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: n >= 1 and a callable is_bad where is_bad(i) is False for i < first and True for i >= first. Output: first. Assume at least one bad build; if none is guaranteed, return -1 when is_bad(n) is Fal...
High-Level Design
The predicate is monotonic: a run of Falses followed by Trues. Binary search for the boundary. Keep the invariant that the answer lies in [lo, hi]. If mid is bad, the answer is mid or earlier, so set ...