Created
December 29, 2020 19:24
-
-
Save ahmet-cetinkaya/5a63e8c8bc905fd1ecc5739376a99540 to your computer and use it in GitHub Desktop.
LeetCode Solution 278. First Bad Version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const solution = (isBadVersion) => (n) => { | |
let left = 1, | |
right = n; | |
while (left < right) { | |
const middle = Math.floor(left + (right - left) / 2); | |
if (isBadVersion(middle)) right = middle; | |
else left = middle + 1; | |
} | |
return left; | |
}; |
Author
ahmet-cetinkaya
commented
Dec 29, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment