# Test Case Missing

• My Following Code is ACCEPTED but it's not passing following test case.

``````[2,2,2,2,1,2,2,2,2,2,2,2,2]
``````
``````class Solution(object):
def findMin(self, nums):

low = 0
high = len(nums) - 1

if nums[low] < nums[high]:
return nums[low]

ans = self.search(nums, low, high)
if ans == sys.maxint:
return nums[low]
else:
return ans

def search(self, nums, low, high):
"""
:type nums: List[int]
:rtype: int
"""

if low > high:
return sys.maxint

middle = (low + high)/2
if middle < high and nums[middle] > nums[middle + 1]:
return nums[middle + 1]
if middle > 0 and nums[middle - 1] > nums[middle]:
return nums[middle]
elif nums[low] < nums[middle]:
return self.search(nums, middle, high)
elif nums[middle] < nums[high]:
return self.search(nums, low, middle)
else:
if nums[low] == nums[middle] and nums[middle] != nums[high]:
return self.search(nums, middle + 1, high)

if nums[low] != nums[middle] and nums[middle] == nums[high]:
return self.search(nums, low, middle - 1)

if middle > 0 and nums[middle] != nums[middle - 1]:
return self.search(nums, low, middle - 1)
else:
return self.search(nums, middle + 1, high)

``````

Correct Solution is Following:

``````class Solution(object):
def findMin(self, nums):

low = 0
high = len(nums) - 1

if nums[low] < nums[high]:
return nums[low]

ans = self.search(nums, low, high)
if ans == -1:
return nums[low]
else:
return nums[ans]

def search(self, nums, low, high):
"""
:type nums: List[int]
:rtype: int
"""

if low > high:
return -1

middle = (low + high)/2
if middle < high and nums[middle] > nums[middle + 1]:
return middle + 1
if middle > 0 and nums[middle - 1] > nums[middle]:
return middle
elif nums[low] < nums[middle]:
return self.search(nums, middle, high)
elif nums[middle] < nums[high]:
return self.search(nums, low, middle)
else:
if nums[low] == nums[middle] and nums[middle] != nums[high]:
return self.search(nums, middle + 1, high)

ans = self.search(nums, low, middle - 1)
if ans != -1:
return ans
else:
return self.search(nums, middle + 1, high)

``````