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 eced7a5 commit c234e29Copy full SHA for c234e29
EASY/src/easy/FirstBadVersion.java
@@ -0,0 +1,25 @@
1
+package easy;
2
+
3
+public class FirstBadVersion {
4
5
+ public int firstBadVersion(int n) {
6
+ int left = 1, right = n;
7
+ if(isBadVersion(left)) return left;
8
9
+ while(left+1 < right){
10
+ int mid = left + (right-left)/2;
11
+ if(isBadVersion(mid)) right = mid;
12
+ else left = mid;
13
+ }
14
15
16
+ return right;
17
18
19
+ private boolean isBadVersion(int left) {
20
+ //this is a fake method to make Eclipse happy
21
+ return false;
22
23
24
25
+}
0 commit comments