Skip to content

Commit 785e63b

Browse files
committed
Update solution 153 [Python3]
1 parent 18054c8 commit 785e63b

File tree

1 file changed

+30
-0
lines changed
  • solution/153.Find Minimum in Rotated Sorted Array

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class Solution:
2+
def findMin(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: int
6+
"""
7+
return min(nums)
8+
9+
class Solution:
10+
def findMin(self, nums):
11+
"""
12+
:type nums: List[int]
13+
:rtype: int
14+
"""
15+
length=len(nums)
16+
if length == 1:
17+
return nums[0]
18+
l=0
19+
r=length-1
20+
m=r//2
21+
22+
while l<r:
23+
if nums[l]<=nums[r]:
24+
break
25+
if nums[l]>nums[m]:
26+
r=m
27+
else:
28+
l=m+1
29+
m=(l+r)//2
30+
return nums[l]

0 commit comments

Comments
 (0)