#81
Search in Rotated Sorted Array II
expert · 1020 · lc medium +32 · verified · 39.8% accepted · 9,577 likes · top 19%
Description
An integer array sorted in non-decreasing order (possibly with duplicates) was rotated at an unknown pivot. Determine whether target exists in the rotated array, reducing operations as much as possible.
Example 1:
Input: nums = [2,5,6,0,0,1,2], target = 0
Output: true
Example 2:
Input: nums = [2,5,6,0,0,1,2], target = 3
Output: false
Code
1
2
3