File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
Leetcode/0153.Find-Minimum-in-Rotated-Sorted-Array Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 8080https://github.com/kimi0230/LeetcodeGolang/blob/master/Leetcode/0153.Find-Minimum-in-Rotated-Sorted-Array/main.go
8181
8282``` 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+ }
83102
84103```
85104
Original file line number Diff line number Diff line change @@ -482,10 +482,11 @@ func RightBound(nums []int, target int) (index int) {
482482 return right
483483}
484484```
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 |
489490
490491
491492-- -
You can’t perform that action at this time.
0 commit comments