DIY: First Bad Version
Solve the interview question "First Bad Version" in this lesson.
We'll cover the following
Problem statement
The latest version of a software product fails the quality check. Since each version is developed upon the previous one, all the versions created after a bad version are also considered bad.
Suppose you have n
versions with the following IDs:[1, 2, ..., n]
. Your task is to find the first bad one, which is causing all the later ones to be bad.
Consider that you have the access to an API call, API.is_bad_version(id_1, id_2)
, that returns true
if the argument is the ID of a bad version. You have to implement a solution with the minimum number of API calls.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.