My Solution,6ms


  • 0
    C

    class Solution {
    public:
    int findMin(vector<int>& nums) {
    int size = nums.size();
    int L = 0, R = size-1;

        if(nums[R] > nums[L]) return nums[L];
    
        while(nums[L] > nums [R]){
            int M = (L + R) / 2;
            if(nums[M] == nums[L]){
                if(nums[R] > nums[L]) return nums[L];
                else return nums[R];
            }else if(nums[L] < nums[M]) L = M;
            else R = M;
        }
    
        return nums[L];
    }
    

    };


Log in to reply
 

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