mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2024-12-27 12:56:17 +00:00
add lc153 code in go
This commit is contained in:
parent
5fcc995b70
commit
3f2fb1967f
@ -111,3 +111,26 @@ public:
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Go Code:
|
||||||
|
|
||||||
|
```go
|
||||||
|
func findMin(nums []int) int {
|
||||||
|
left := 0
|
||||||
|
right := len(nums) - 1
|
||||||
|
|
||||||
|
for (left < right) {
|
||||||
|
|
||||||
|
if (nums[left] < nums[right]) {
|
||||||
|
return nums[left]
|
||||||
|
}
|
||||||
|
mid := left + ((right - left) >> 1)
|
||||||
|
if (nums[left] > nums[mid]) {
|
||||||
|
right = mid
|
||||||
|
} else {
|
||||||
|
left = mid + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nums[left]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user