First Bad Version

Easy
Binary SearchAmazonMeta
Versions are numbered 1 to n. Every version from some version b onward is bad, and all earlier versions are good, so the `is bad` property is monotonic. You are told n and b. Using the fewest checks (binary search over the monotonic boolean sequence), find and print the first bad version. Input format: - One line: n b

Constraints

1 <= b <= n <= 2 * 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit