LeetCode 278. First Bad Version Posted on 2021-06-13 Edited on 2024-11-24 In LeetCode 123456789101112class Solution {public: int firstBadVersion(int n) { int l = 1, r = n; while (l < r) { int mid = (r - l) / 2 + l; if (isBadVersion(mid)) r = mid; else l = mid + 1; } return l; }};