【第22期】观点:IT 行业加班,到底有没有价值?

[leetcode]153. Find Minimum in Rotated Sorted Array

原创 2016年08月28日 15:02:22
class Solution {
public:
    int findMin(vector<int>& nums) {
        int len=nums.size();
        return find(nums,0,len-1);
    }
    int find(vector<int>&nums,int l,int r )
    {
        if(l==r)
            return nums[l];
        int m=(l+r)/2;
        
        if(nums[l]<=nums[m]&&nums[m]<=nums[r])
        
            return nums[l];
        if(nums[l]>=nums[m]&&nums[m]>=nums[r])
            return nums[r];
            
        if(nums[l]>nums[r]&&nums[m]<nums[r])
        
            return find(nums,l,m);
            
        return find(nums,m,r);
        
    }
};

版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

leetcode解题之153&154. Find Minimum in Rotated Sorted Array版(在旋转的数组中查找最小数字)

leetcode解题之153&154. Find Minimum in Rotated Sorted Array版(在旋转的数组中查找最小数字)

[LeetCode]154.Find Minimum in Rotated Sorted Array II

【题目】 <blockquote style="padding: 10px 20px; margin: 0px 0px 20px; font-size: 17.5px; border-left-width: 5px; border-left-style: solid; bord...

程序员升职加薪指南!还缺一个“证”!

CSDN出品,立即查看!

[LeetCode]153.Find Minimum in Rotated Sorted Array

【题目】 Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 ...

[LeetCode]153.Find Minimum in Rotated Sorted Array

【题目】 Suppose a sorted array is rotated at some pivot unknown to you beforehan

Leetcode 153. Find Minimum in Rotated Sorted Array (Medium) (cpp)

Leetcode 153. Find Minimum in Rotated Sorted Array (Medium) (cpp)
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)