First Bad Version

0Easy

First Bad Version

You have n versions [1..n]. isBadVersion(version) tells if a version is bad. All versions after the first bad one are also bad. Find the first bad version minimizing API calls using binary search.

Example 1:

n = 5, bad = 4 → isBadVersion(3)=false, isBadVersion(5)=true, isBadVersion(4)=true → Output: 4

Example 2:

n = 1, bad = 1 → Output: 1

JR

Jnaneshwara Reddy Satti

Builder · ClearCode

Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕

If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.

Support via Razorpay
Support ClearCode ☕
First Bad Version — Easy Arrays Algorithm | ClearCode