Find Minimum in Rotated Sorted Array问题的困惑

今天做了两题,第二题没解出来,发现太麻烦了,放弃了……明天脑子清楚的时候再做。

第一题就是标题中的这个问题。在一个旋转排序数组中找出最小的值。

针对该问题出了两道不同要求的题目,分别是不考虑重复元素的情况和考虑有重复元素的情况。

我的解题思路是,将数组的第一个值存到变量中,循环数组剩余的值,进行比较,第一个比该变量中存的数小的值就是数组中最小的值,将其赋值给该变量,并返回。

两种要求用上面的解题思路均ac了。自己思考也觉得没错,那么问题来了,为什么要加这个要求的区别呢?到底差在哪里?

此困惑当前无法解决,放置于此,以待后续。

时间: 2024-09-30 05:42:43

Find Minimum in Rotated Sorted Array问题的困惑的相关文章

Leetcode[154]-Find Minimum in Rotated Sorted Array II

Link: https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/ Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is

[leedcode 154] Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might be

LeetCode Find Minimum in Rotated Sorted Array II

Find Minimum in Rotated Sorted Array II Total Accepted: 23090 Total Submissions: 73108 My Submissions Question Solution Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexi

【LeetCode】Find Minimum in Rotated Sorted Array 在旋转数组中找最小数

Add Date 2014-10-15 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 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in the

Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might be

Leetcode#153Find Minimum in Rotated Sorted Array

Find Minimum in Rotated Sorted Array Total Accepted: 42341 Total Submissions: 127863My Submissions Question Solution 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

Leetcode#154Find Minimum in Rotated Sorted Array II

Find Minimum in Rotated Sorted Array II Total Accepted: 25678 Total Submissions: 80978My Submissions Question Solution Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity

Find Minimum in Rotated Sorted Array II -- LeetCode

这道题是Search in Rotated Sorted Array的扩展,思路在Find Minimum in Rotated Sorted Array中已经介绍过了,和Find Minimum in Rotated Sorted Array唯一的区别是这道题目中元素会有重复的情况出现.不过正是因为这个条件的出现,影响到了算法的时间复杂度.原来我们是依靠中间和边缘元素的大小关系,来判断哪一半是不受rotate影响,仍然有序的.而现在因为重复的出现,如果我们遇到中间和边缘相等的情况,我们就无法判

LeetCode 新题: Find Minimum in Rotated Sorted Array II 解题报告-二分法模板解法

Find Minimum in Rotated Sorted Array II Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unknown to you be