Loading
Loading
A build pipeline produced a sequence of builds. Every build after some point is broken, and every build before it is fine — once it breaks, it stays broken.
Given an array of build statuses where 0 is passing and 1 is failing, return the index of the first failing build, or the array length if none fail.
builds = [0, 0, 0, 1, 1]lo=0 hi=4, mid=2 → 0still passing, discard the left halflo=3 hi=4, mid=3 → 1failing, keep it as a candidatelo=3 hi=3boundary found3Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(log n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Example 2
The very first build fails.
Example 3
Nothing fails, so the answer is the array length.