这道题与 153 Find Minimum in Rotated Sorted Array 基本相同,只是有可能有重复的数字, 这样a[left] 就可能与a[mid]相同 因此就多一个可能,因此在最坏的情况下复杂度会是O(n)

class Solution:# @param {integer[]} nums# @return {integer}def findMin(self, nums):l = len(nums) - 1if l <= 1:return min(nums)mid = l / 2if nums[0] < nums[mid]:return self.findMin([nums[0]] + nums[mid+1:])elif nums[0] > nums[mid]:return self.findMin(nums[1:mid+1])else:return min(self.findMin(nums[0:mid]),self.findMin(nums[mid+1:]))

转载于:https://www.cnblogs.com/dapanshe/p/4632808.html

154 Find Minimum in Rotated Sorted Array 2相关推荐

  1. 【LeetCode】154. Find Minimum in Rotated Sorted Array II (3 solutions)

    Find Minimum in Rotated Sorted Array II Follow up for "Find Minimum in Rotated Sorted Array&quo ...

  2. 154. Find Minimum in Rotated Sorted Array II

    文章目录 题目理解 二分+分治 只有二分 154是 153的升级版本. 题目理解 输入:一个按升序排序的数组nums,但是这个数组在某个位置被旋转了.(例如., 原始数组是[0,1,2,4,5,6,7 ...

  3. LeetCode Find Minimum in Rotated Sorted Array II

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

  4. Find Minimum in Rotated Sorted Array II

    Description: Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are ...

  5. LeetCode——Find Minimum in Rotated Sorted Array II

    Question Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allo ...

  6. LeetCode 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 6 7 migh ...

  7. (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 6 7 migh ...

  8. [LeetCode]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 6 ...

  9. 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 6 7 migh ...

最新文章

  1. About Firefox
  2. JSF----事件处理---动作事件
  3. Redux源码全篇浅读
  4. arcgis几何修复有作用吗_修复损坏的 shapefile
  5. php能干哪些副业,做副业,在能干的基础上踏实肯干
  6. c语言学生综合测评系统_综合测评线上系统帮助文档
  7. php oracle 存储过程 返回值,PHP 调用 Oracle 存储过程 之 查询
  8. 过目不忘JS正则表达式(转)
  9. 计算可靠度编制matlab,工程结构可靠度计算的Matlab实现
  10. vs2019编译的程序在win7环境上运行失败
  11. 让硬盘灯不再狂闪,调整Win7系统绝技(转)
  12. iOS开发-ZFPlayer的简单使用 播放单个网络视频
  13. Jquery UI中 Dialog对象的作用及常用属性
  14. 模式识别作业2——SYSU
  15. 人物照片墙html模板,制作散落照片墙效果人物照片的PS教程
  16. CSAPP-Lab05 Cache Lab 深入解析
  17. Codeforce 712A Memory and Crow
  18. 南澳州政府拒绝更换DOS病历软件:称为患者安全着想
  19. e-icon-picker
  20. UIUC罗宇男:交叉学科中的人工智能和科学发现

热门文章

  1. Windows Azure虚拟机概览
  2. Camtasia Studio 7 试用笔记
  3. 图像识别工程师 VS The application has requested the Runtime to terminate it in an unusual way.
  4. 优秀的Java程序员必须了解GC的工作原理
  5. java 热替换_class卸载、热替换和Tomcat的热部署的分析
  6. 如何将DATASET的数据导出到XML文件,并直接下载
  7. 日本奥委会主席否认为争取奥运会主办权行贿
  8. 【跃迁之路】【678天】程序员高效学习方法论探索系列(实验阶段435-2018.12.23)...
  9. Reverse Integer
  10. django 1.9 后台中文界面