First Bad Version

You have versions 1 to n and a function isBadVersion(version) which returns whether a version is bad. Find the first bad version by minimizing calls to the API.

Examples

Example 1:

Input:

n = 5
bad = 4

Output:

4

Example 2:

Input:

n = 1
bad = 1

Output:

1
Loading...
First Bad Version - Binary Search DSA Problem