We’re preparing your current view and syncing the latest data.
Given an integer array nums sorted in non-decreasing order, which is rotated at an unknown pivot and may contain duplicates, write a function to search for a given target value. Return true if target is found in the array, otherwise return false.
An integer array nums and an integer target.
Boolean value true if target exists in nums, otherwise false.
1 <= nums.length <= 5000 -10^4 <= nums[i] <= 10^4 -10^4 <= target <= 10^4
Example 1
Input
nums = [2,5,6,0,0,1,2], target = 0
Output
true
Explanation
0 is present in the rotated sorted array.
Example 2
Input
nums = [2,5,6,0,0,1,2], target = 3
Output
false
Explanation
3 is not present in the array.