112. Search in rotated sorted array-II
Given an integer array nums, sorted in ascending order (may contain duplicate values) and a target value k. Now the array is rotated at some pivot point unknown to you. Return True if k is present and otherwise, return False.
Example 1:
Input :Â nums = [7, 8, 1, 2, 3, 3, 3, 4, 5, 6], k = 3
Output: True
Explanation: The element 3 is present in the array. So, the answer is True.
Example 2:
Input : nums = [7, 8, 1, 2, 3, 3, 3, 4, 5, 6], k = 10
Output: False
Explanation:The element 10 is not present in the array. So, the answer is False.
Now Your Turn!
Pick the correct output for the given inputInput : nums = [7, 8, 1, 2, 3, 3, 3, 4, 5, 6], k = 7
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- Â Â 1 <= nums.length <= 104
- Â Â -104 <= nums[i] <= 104
- Â Â nums is guaranteed to be rotated at some pivot.
- Â Â -104 <= k <= 104