bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 278. First Bad Version

278. First Bad Version

Leetcode Solutions

Binary Search to Find First Bad Version

  1. Initialize two pointers, left at 1 and right at n.
  2. While left is less than right, do the following: a. Calculate the middle of the current search space as mid = left + (right - left) // 2. b. If isBadVersion(mid) is True, set right to mid. c. Otherwise, set left to mid + 1.
  3. After the loop, left will be the first bad version.
UML Thumbnail

Linear Scan to Find First Bad Version

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...