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 11/**
22 * Definition for isBadVersion()
3- *
3+ *
44 * @param {integer } version number
55 * @return {boolean } whether the version is bad
66 * isBadVersion = function(version) {
1212 * @param {function } isBadVersion()
1313 * @return {function }
1414 */
15- var solution = function ( isBadVersion ) {
15+ var solution = function ( isBadVersion ) {
1616 /**
1717 * @param {integer } n Total versions
1818 * @return {integer } The first bad version
1919 */
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 ;
2929 }
30- return low ;
30+ }
31+ return low ;
3132 } ;
32- } ;
33+ } ;
You can’t perform that action at this time.
0 commit comments