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
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
binary search
monotonic predicate
lower bound
API call minimization
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported