File tree 2 files changed +24
-4
lines changed
Leetcode/0153.Find-Minimum-in-Rotated-Sorted-Array
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 80
80
https://github.com/kimi0230/LeetcodeGolang/blob/master/Leetcode/0153.Find-Minimum-in-Rotated-Sorted-Array/main.go
81
81
82
82
``` go
83
+ package findminimuminrotatedsortedarray
84
+
85
+ // 時間複雜 O(logN), 空間複雜 O(1)
86
+ func findMin (nums []int ) int {
87
+ left , right := 0 , len (nums)-1
88
+ for left < right {
89
+ if nums[left] < nums[right] {
90
+ return nums[left]
91
+ }
92
+ mid := int (uint (left+right) >> 1 )
93
+ if nums[mid] >= nums[left] {
94
+ // mid 一定不是最小值了
95
+ left = mid + 1
96
+ } else {
97
+ right = mid
98
+ }
99
+ }
100
+ return nums[left]
101
+ }
83
102
84
103
```
85
104
Original file line number Diff line number Diff line change @@ -482,10 +482,11 @@ func RightBound(nums []int, target int) (index int) {
482
482
return right
483
483
}
484
484
```
485
- | No. | Title | Solution | Difficulty | Time | Space | Topic |
486
- | -------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------ :| :---------------------------------------------------------------------------------------------- :| ------------ | -------------------------------------- - | ------------------------------ - | -------------- - |
487
- | [0704 ](https:// kimi0230.github.io/ LeetcodeGolang/ Leetcode/ 0704. Binary- Search/ ) | [704 . Binary Search](https:// leetcode.com/ problems/ binary- search/ ) | [Go](https:// github.com/ kimi0230/ LeetcodeGolang/ tree/ master/ Leetcode/ 0704. Binary- Search) | Easy | 最差:O(long n)< br> 最佳O(1 )剛好在中間 | 迭代: O(1 ) < br/ > 遞迴O(log n) | Binary Search |
488
- | [0875 ](https:// kimi0230.github.io/ LeetcodeGolang/ Leetcode/ 0875. Koko- Eating- Bananas/ ) | [875 . Koko Eating Bananas](https:// leetcode.com/ problems/ koko- eating- bananas/ description/ ) | [Go](https:// github.com/ kimi0230/ LeetcodeGolang/ tree/ master/ Leetcode/ 0875. Koko- Eating- Bananas) | Medium | O(n log m) | O(1 ) | Binary Search |
485
+ | No. | Title | Solution | Difficulty | Time | Space | Topic |
486
+ | ------------------------------------------------------------------------------------------------------ - | :---------------------------------------------------------------------------------------------------------------------------- :| :-------------------------------------------------------------------------------------------------------------- - :| ------------ | -------------------------------------- - | ------------------------------ - | -------------- - |
487
+ | [0704 ](https:// kimi0230.github.io/ LeetcodeGolang/ Leetcode/ 0704. Binary- Search/ ) | [704 . Binary Search](https:// leetcode.com/ problems/ binary- search/ ) | [Go](https:// github.com/ kimi0230/ LeetcodeGolang/ tree/ master/ Leetcode/ 0704. Binary- Search) | Easy | 最差:O(long n)< br> 最佳O(1 )剛好在中間 | 迭代: O(1 ) < br/ > 遞迴O(log n) | Binary Search |
488
+ | [0875 ](https:// kimi0230.github.io/ LeetcodeGolang/ Leetcode/ 0875. Koko- Eating- Bananas/ ) | [875 . Koko Eating Bananas](https:// leetcode.com/ problems/ koko- eating- bananas/ description/ ) | [Go](https:// github.com/ kimi0230/ LeetcodeGolang/ tree/ master/ Leetcode/ 0875. Koko- Eating- Bananas) | Medium | O(n log m) | O(1 ) | Binary Search |
489
+ | [0153 ](https:// kimi0230.github.io/ LeetcodeGolang/ Leetcode/ 0153. Find- Minimum- in - Rotated- Sorted- Array/ ) | [153 . Find Minimum in Rotated Sorted Array](https:// leetcode.com/ problems/ find- minimum- in - rotated- sorted - array/ description/ ) | [Go](https:// github.com/ kimi0230/ LeetcodeGolang/ tree/ master/ Leetcode/ 0153. Find- Minimum- in - Rotated- Sorted- Array) | Medium | O(log n) | O(1 ) | Binary Search |
489
490
490
491
491
492
-- -
You can’t perform that action at this time.
0 commit comments