33. Search in Rotated Sorted Array
https://leetcode.com/problems/search-in-rotated-sorted-array/
solution
根据rotate的不同,分为两种情况。能用二分是因为可以确保总有一个分支能确保是排序的
每种情况分别执行二分搜索
时间复杂度:O(log(n)) 空间复杂度:O(1)
follow up
81. Search in Rotated Sorted Array II
153. Find Minimum in Rotated Sorted Array
求旋转排序数组最大最小值
最大值:The maximum element is the only element whose next is smaller than it
最大值:如果最大值不是mid或mid+1, 中间大于最后值则最大值位于左边,否则位于右边
时间复杂度:O(log(n)) 空间复杂度:O()
154. Find Minimum in Rotated Sorted Array II
Previous34. Find First and Last Position of Element in Sorted ArrayNext81. Search in Rotated Sorted Array II
Last updated