33. Search in Rotated Sorted Array

# Medium

Solution

Case 1: no rotated, just do binary search as regular

Case 2: is rotated, find the pivot, and do binary search in one of two parts

Consider edge case: 0 element

How to find the pivot?

Better solution:

  1. find the smallest element in the array which is the pivot.

  2. only search left or right part of this array by Binary Search

Last updated

Was this helpful?