Skip to content

Commit ba7a592

Browse files
committed
add Step3
1 parent aa05929 commit ba7a592

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

278/step3.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int firstBadVersion(int n) {
4+
int left = 1;
5+
int right = n;
6+
7+
while (left <= right) {
8+
int mid = left + (right - left) / 2;
9+
if (isBadVersion(mid)) {
10+
right = mid - 1;
11+
} else {
12+
left = mid + 1;
13+
}
14+
}
15+
return left;
16+
}
17+
};

0 commit comments

Comments
 (0)