fast (6ms) and concise c++ solution (11lines)


  • 0
    Q
    class Solution {
    public:
        int findMin(vector<int>& nums) {
            return findMin(nums, 0, nums.size() - 1);
        }    
        int findMin(vector<int>& nums, int start, int end) {
            if (nums[start] < nums[end] || start == end) return nums[start];
            int mid = (start + end)/2;
            return min(findMin(nums, start, mid), findMin(nums, mid+1, end));
        }
    };
    

Log in to reply
 

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