add new solutions
This commit is contained in:
parent
d798d5e8c9
commit
886b5e0a8e
34 changed files with 1164 additions and 0 deletions
18
solutions/1/q153/solution.go
Normal file
18
solutions/1/q153/solution.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package q153
|
||||
|
||||
func findMin(nums []int) int {
|
||||
l, r := 0, len(nums)
|
||||
|
||||
for l < r && nums[l] > nums[r-1] {
|
||||
m := (l + r) / 2
|
||||
if nums[m] > nums[r-1] {
|
||||
l = m + 1
|
||||
} else {
|
||||
r = m + 1
|
||||
l++
|
||||
}
|
||||
}
|
||||
return nums[l]
|
||||
}
|
||||
|
||||
var _ = findMin
|
||||
Loading…
Add table
Add a link
Reference in a new issue