My c solution using binary search


  • 2
    H
    int findMin(int* nums, int numsSize) {
        if(numsSize<=0)
            return 0;
        int min=nums[numsSize-1];
        int i=0,j=numsSize-1;
        while(i<=j){
            int t=i+(j-i)/2;
            if(nums[t]>min)
                i=t+1;
            else{
                j=t-1;
                min=nums[t];
            }
        }
        return min;
    }
    

Log in to reply
 

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