Sharing my 8ms C++ solution


  • 0
    T
    class Solution {
    public:
        int findMin(vector<int>& nums) {
            int left = 0;
            int right = nums.size()-1;
            int middle;
            while(left<right)
            {
                middle = (left+right)/2;
                if(nums[middle]>nums[right])
                    left = middle+1;
                else if(nums[middle]<nums[right])
                    right = middle;
                else
                    right--;
            }
            
            return nums[left];
        }
    };

Log in to reply
 

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