Problem
Ask
Submissions

Problem: First Bad Version

Medium
30 min
Explore how to determine the first bad version in a sequence of software releases by applying a modified binary search. Understand the problem constraints and implement an efficient solution that minimizes API calls to isBadVersion. This lesson helps you practice an essential pattern for solving search problems in coding interviews.

Statement

You are managing a product development team, and the latest release has failed quality checks. Because each version is built on top of the previous one, once a version is bad, every version after it is also bad.

You are given an array of n versions [1,2,,n][1, 2, …, n], and your task is to determine the first version in this sequence that is bad—the version that causes all later versions to be bad as well.

You have access to an API isBadVersion(version) that returns TRUE if a given version is bad.

Your task is to find the first bad version while minimizing the number of calls to this API.

Constraints:

  • 11 \leq bad \leq n 105\leq 10^5

Problem
Ask
Submissions

Problem: First Bad Version

Medium
30 min
Explore how to determine the first bad version in a sequence of software releases by applying a modified binary search. Understand the problem constraints and implement an efficient solution that minimizes API calls to isBadVersion. This lesson helps you practice an essential pattern for solving search problems in coding interviews.

Statement

You are managing a product development team, and the latest release has failed quality checks. Because each version is built on top of the previous one, once a version is bad, every version after it is also bad.

You are given an array of n versions [1,2,,n][1, 2, …, n], and your task is to determine the first version in this sequence that is bad—the version that causes all later versions to be bad as well.

You have access to an API isBadVersion(version) that returns TRUE if a given version is bad.

Your task is to find the first bad version while minimizing the number of calls to this API.

Constraints:

  • 11 \leq bad \leq n 105\leq 10^5