The versions form a pattern: [good, good, good, bad, bad, bad]. You need to find the first bad. This is exactly lower bound: find the first position where a condition becomes true.
1. Set left = 1, right = n.
2. While left < right, compute mid = left + (right - left) / 2.
3. If isBadVersion(mid) is true, the first bad is at mid or earlier. Set right = mid.
4. Otherwise, set left = mid + 1.
5. Return left.