8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df4da2a commit 89ef2aeCopy full SHA for 89ef2ae
May-LeetCoding-Challenge/First-Bad-Version/First-Bad-Version.cpp
@@ -0,0 +1,17 @@
1
+// The API isBadVersion is defined for you.
2
+// bool isBadVersion(int version);
3
+
4
+class Solution {
5
+public:
6
+ int firstBadVersion(int n) {
7
+ int left = 1, right = n;
8
+ while (left < right){
9
+ int mid = (right - left) / 2 + left;
10
+ if (isBadVersion(mid))
11
+ right = mid;
12
+ else left = mid + 1;
13
+ }
14
+ return left;
15
16
+};
17
0 commit comments