Skip to main content

Practice ยท 3 of 3

Bisect Simulator

bisect(commits, isBad) โ€” commits is an ordered array of ids oldest-first; isBad(id) returns a boolean. Simulate binary search: probe the middle, discard the half that cannot contain the FIRST bad commit, repeat. Return the id of the first bad commit (probe count must not exceed ceil(log2(n)) + 2 โ€” efficiency matters).

Difficulty: intermediate

Back to lesson: Practice: History as Data โ€” Practice