This question same as find the minimum in sorted array exist duplicate element


  • 0
    J
    class Solution {
    public:
        int firstBadVersion(int n) {
            long i=1,j=n;
            while(i<j){
                long m=(i+j)/2;
                if(!isBadVersion(m)){
                    i=m+1;
                }else{
                    j=m;
                }
            }
            return i;
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.