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.
n = 5, bad = 4 → isBadVersion(3)=false, isBadVersion(5)=true, isBadVersion(4)=true → Output: 4
n = 1, bad = 1 → Output: 1
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.