Practice · 1 of 3
Pipeline Bisection
CHALLENGE
Difficulty: intermediate+25 XP
stages is an ordered array of stage ids; inspect(stageId) returns true if that stage's OUTPUT is already wrong. Write firstBadStage(stages, inspect) returning the id of the FIRST stage whose output is wrong (or null if all good). Must probe at most ceil(log2(n)) + 2 times — binary search the boundary.
Press Submit to check your solution.
Back to lesson: Practice: Diagnose From Evidence — Practice