Search in Rotated Sorted Array II
medium 原题链接:https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
最后更新于
这有帮助吗?
medium 原题链接:https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
最后更新于
这有帮助吗?
原题链接:
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e.,
[0,0,1,2,2,5,6]
might become[2,5,6,0,0,1,2]
).You are given a target value to search. If found in the array return
true
, otherwise returnfalse
.
Input: nums = [2,5,6,0,0,1,2], target = 0
Output: true
Input: nums = [2,5,6,0,0,1,2], target = 3
Output: false
This is a follow up problem to , where
nums
may contain duplicates.Would this affect the run-time complexity? How and why?
二分查找法
分析:T=O(n), S=O(1)
如果nums里用重复的数出现是否会增加时间复杂度?