> For the complete documentation index, see [llms.txt](https://hao-fu-1.gitbook.io/oj/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hao-fu-1.gitbook.io/oj/binarysearch/search-in-rotated-sorted-array-ii.md).

# Search in Rotated Sorted Array II

<https://leetcode.com/problems/search-in-rotated-sorted-array-ii/description/>

> Follow up for "Search in Rotated Sorted Array":\
> What if duplicates are allowed?
>
> Would this affect the run-time complexity? How and why?

## Tips

不能再用binary search了，因为pivot elements可以重复后start 和end都可以等于pivot, 无法再判断mid是在前段还是后段。

## Code

```
class Solution {    
    public boolean search(int[] nums, int target) {
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == target) {
                return true;
            }
        }

        return false;
    }
}
```

## Analysis

O(n)
