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.
Example 1:
Input:
n = 5 bad = 4
Output:
4
Example 2:
n = 1 bad = 1
1