MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / search

Method search

Array/SearchInRotatedSortedArrayII.py:82–103  ·  view source on GitHub ↗

:type nums: List[int] :type target: int :rtype: int

(self, nums, target)

Source from the content-addressed store, hash-verified

80
81
82 def search(self, nums, target):
83 """
84 :type nums: List[int]
85 :type target: int
86 :rtype: int
87 """
88 if not nums:
89 return False
90
91 rotate_index = self.find_rotate(nums)
92
93 lo = 0
94 hi = rotate_index
95
96 one = self.bi_search(nums, target, lo, hi)
97 if one != -1:
98 return True
99
100 two = self.bi_search(nums, target, hi, len(nums))
101 if two != -1:
102 return True
103 return False

Callers

nothing calls this directly

Calls 2

find_rotateMethod · 0.95
bi_searchMethod · 0.95

Tested by

no test coverage detected