Hard-题目5:154. Find Minimum in Rotated Sorted Array II

原创 2016年05月31日 23:23:16

题目原文:
Suppose a sorted array is rotated at some pivot unknown to you beforehand.

(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).

Find the minimum element.

The array may contain duplicates.
题目大意:
对一个移位后的排序数组(可能存在重复数字)求最小元素。
题目分析:
从头扫一遍即可。也可以通过找跳转点(从最大值突变到最小值,期望是暴力枚举法的1/2)
源码:(language:java)

public class Solution {
    public int findMin(int[] nums) {
        int min = Integer.MAX_VALUE;
        for(int num : nums)
            min=Math.min(num,min);
        return min;
    }
}

成绩:
1ms,beats 5.33%,众数1ms,94.67%

版权声明:完整版Leetcode题解请出门左转https://github.com/cmershen1/leetcode/tree/master/docs

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

Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this a...

【leetcode】No.154 Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this aff...

LeetCode 154. Find Minimum in Rotated Sorted Array II

旋转数组的最小值
  • VDUYI
  • VDUYI
  • 2017年04月11日 20:05
  • 178

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

题目: Follow up for “Find Minimum in Rotated Sorted Array”: What if duplicates are allowed?Would thi...

154 Find Minimum in Rotated Sorted Array II [Leetcode]

题目内容: Follow up for “Find Minimum in Rotated Sorted Array”: What if duplicates are allowed? ...

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

【题目】 Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would t...

LeetCode(154) Find Minimum in Rotated Sorted Array II

题目Follow up for “Find Minimum in Rotated Sorted Array”: What if duplicates are allowed?Would this a...
  • fly_yr
  • fly_yr
  • 2015年10月31日 14:02
  • 309

154. Find Minimum in Rotated Sorted Array II \ 128. Longest Consecutive Sequence

Find Minimum in Rotated Sorted Array II 题目解析 代码实现154. Find Minimum in Rotated Sorted Array II题目解析Sup...

leetcode:154. Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this a...

LeetCode(154) Find Minimum in Rotated Sorted Array II

题目如下: Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would t...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Hard-题目5:154. Find Minimum in Rotated Sorted Array II
举报原因:
原因补充:

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