Description
Find the first bad version given n versions where isBad(version) returns true for bad versions. Return the array [firstBadVersion].
Examples
Input:
n = 5, bad = 4Output:
4Explanation:
Versions 4 and 5 are bad, first is 4.
Input:
n = 3, bad = 1Output:
1Explanation:
All versions 1, 2, and 3 are bad since bad versions are consecutive from the first bad one. The first bad version is 1.
Input:
n = 8, bad = 8Output:
8Explanation:
Only the last version (version 8) is bad. Versions 1 through 7 are good, so the first and only bad version is 8.
Constraints
- •
1 ≤ n ≤ 2³¹ - 1