/* The isBadVersion API is defined in the parent class VersionControl.

boolean isBadVersion(int version); */

public class Solution extends VersionControl {

```
public int firstBadVersion(int n) {
if(n==0) {
return 0;
}
return helper(n,1,n);
}
public int helper(int n, int start, int end) {
if(start>=end) {
return start;
}
int middle = start+(end-start)/2;
if(isBadVersion(middle)) {
return helper(n,start,middle);
} else {
return helper(n,middle+1,end);
}
}
```

}