simple C solution


  • 0
    int Min3(int a,int b,int c) {
        int temp1,temp2;
        
        temp1=(a<b)?a:b;
        temp2=(temp1<c)?temp1:c;
        return temp2;
    }
    
    int findSubMin(int* nums,int start,int end) {
        int startMin,endMin;
        
        if (start==end) return nums[start];
        int mid=(start+end)/2;
    
        startMin=findSubMin(nums,start,mid);
        endMin=findSubMin(nums,mid+1,end);
       
        return Min3(nums[mid],startMin,endMin);
    }
    
    int findMin(int* nums, int numsSize) {
       return findSubMin(nums,0,numsSize-1); 
    }  
    

Log in to reply
 

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