-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathanswer.py
More file actions
25 lines (20 loc) · 681 Bytes
/
answer.py
File metadata and controls
25 lines (20 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
#-------------------------------------------------------------------------------
class Solution(object):
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
l, r = 0, len(nums)-1
# Keep going until we find the fuckywucky equilibrium
while l < r:
mid = (l + r) // 2
# If right is fucked, go to it
if nums[mid] > nums[r]:
l = mid+1
# If left is fucked, go to it
else:
r = mid
return nums[l]
#-------------------------------------------------------------------------------