Search in Rotated Sorted Array II

There is an integer array nums sorted in non-decreasing order, not necessarily with distinct values. The array is rotated at an unknown pivot such that the resulting array may start from any index of the original array. Given this rotated array and an integer target, determine if target is present in nums. The goal is to decrease the overall operation steps as much as possible.

Constraints

  • 1 <= nums.length <= 5000
  • -10000 <= nums[i] <= 10000
  • nums is guaranteed to be rotated at some pivot.
  • -10000 <= target <= 10000
Saving… · 2 lines
class Solution:
def searchInRotatedSortedArrayII(self, nums: List[int], target: int) -> bool:
Console

Click Run to execute sample tests.