We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 18054c8 commit 785e63bCopy full SHA for 785e63b
solution/153.Find Minimum in Rotated Sorted Array/Solution.py
@@ -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
10
11
12
13
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