First Failing Build
A bisect run produced results, one entry per build in order: 0 means the build passed and 1 means it failed. Once a build fails, every later build fails too.
Return the index of the first failing build, or -1 if every build passed. Aim for O(log n).
Example 1
Input: results = [0, 0, 0, 1, 1] Output: 3
Example 2
Input: results = [0, 0] Output: -1
Constraints
- 0 <= results.length <= 10^5
- results is some 0s followed by some 1s.
Hint 1
Search for the boundary between the 0s and the 1s.
Hint 2
Keep a half-open range [lo, hi) and shrink it toward the first 1.
Good practice for: DevOps Engineer, Site Reliability Engineer, Cloud Engineer, Backend Developer, MLOps Engineer, Automation Test Engineer
Run checks your code on 2 sample tests. Submit runs all 7 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.