mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2025-08-15 02:32:30 +00:00
添加Go语言题解
This commit is contained in:
@@ -104,3 +104,23 @@ public:
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Go Code:
|
||||
|
||||
```go
|
||||
func findMin(nums []int) int {
|
||||
l, r := 0, len(nums) - 1
|
||||
for l < r {
|
||||
if nums[l] < nums[r] {
|
||||
return nums[l]
|
||||
}
|
||||
m := l + (r - l) / 2
|
||||
if nums[l] > nums[m] {
|
||||
r = m
|
||||
} else {
|
||||
l = m + 1
|
||||
}
|
||||
}
|
||||
return nums[l]
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user