Skip to content

Commit 10293f7

Browse files
committed
modified Find Minimum in Rotated Sorted Array
1 parent 0587d00 commit 10293f7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
from typing import List
22

3+
34
class Solution:
45
def findMin(self, nums: List[int]) -> int:
56
for i in range(len(nums)):
67
j = i+1 if i < len(nums)-1 else 0
78
if nums[i] >= nums[j]:
89
return nums[j]
9-
10+
# for i in range(len(nums)):
11+
# if i+1 < len(nums) and nums[i] > nums[i+1]:
12+
# return nums[i+1]
13+
# elif i+1 == len(nums):
14+
# return nums[0]
1015

1116

1217
# test driver
1318
sol = Solution()
14-
nums = [3,4,5,1,2]
19+
nums = [3, 4, 5, 1, 2]
1520
print("Input:", nums)
16-
print("Output:", sol.findMin(nums))
21+
print("Output:", sol.findMin(nums))

0 commit comments

Comments
 (0)