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

Method find_rotate

Array/SearchInRotatedSortedArrayII.py:47–66  ·  view source on GitHub ↗
(self, nums)

Source from the content-addressed store, hash-verified

45"""
46class Solution(object):
47 def find_rotate(self, nums):
48 target = nums[0]
49 lo = 1
50
51 for i in range(1, len(nums)):
52 if nums[i] == target:
53 lo += 1
54 else:
55 break
56
57 hi = len(nums)
58
59 while lo < hi:
60 mid = (lo + hi) // 2
61 if nums[mid] > target:
62 lo = mid + 1
63 else:
64 hi = mid
65
66 return lo
67
68 def bi_search(self, nums, target, lo, hi):
69 while lo < hi:

Callers 1

searchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected