first bad version
2022年5月1日小于 1 分钟
first bad version
Question
Say you have multiple versions of a program, write a program that will find and return the first bad revision given a isBad(version)
function.
Versions after first bad version are supposed to be all bad versions.
notes
- Inputs are all non-negative integers
- if none found, return -1
Code
/*
type IsBad = (version: number) => boolean
*/
/**
* @param {IsBad} isBad
*/
function firstBadVersion(isBad) {
// firstBadVersion receive a check function isBad
// and should return a closure which accepts a version number(integer)
return (version) => {
// write your code to return the first bad version
// if none found, return -1
}
}