File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
solution/0200-0299/0278.First Bad Version Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* Definition for isBadVersion()
3
- *
3
+ *
4
4
* @param {integer} version number
5
5
* @return {boolean} whether the version is bad
6
6
* isBadVersion = function(version) {
12
12
* @param {function} isBadVersion()
13
13
* @return {function}
14
14
*/
15
- var solution = function(isBadVersion) {
15
+ var solution = function (isBadVersion) {
16
16
/**
17
17
* @param {integer} n Total versions
18
18
* @return {integer} The first bad version
19
19
*/
20
- return function(n) {
21
- let low = 1, high = n;
22
- while (low < high) {
23
- const mid = low + (( high - low) >> 1);
24
- if (isBadVersion(mid)) {
25
- high = mid;
26
- } else {
27
- low = mid + 1;
28
- }
20
+ return function (n) {
21
+ let low = 1,
22
+ high = n;
23
+ while ( low < high) {
24
+ const mid = low + ((high - low) >> 1);
25
+ if (isBadVersion( mid)) {
26
+ high = mid;
27
+ } else {
28
+ low = mid + 1;
29
29
}
30
- return low;
30
+ }
31
+ return low;
31
32
};
32
- };
33
+ };
You can’t perform that action at this time.
0 commit comments