Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d906ca

Browse files
committed
NOT YET[03/13] 實際02/19, 154-findMin,HARD
1 parent 855883b commit 7d906ca

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

‎src/154_findMin/algo.go‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package algo
2+
3+
func findMin(nums []int) int {
4+
start:=0
5+
end:= len(nums)-1
6+
for start+1<end{
7+
middle := (start+end)/2
8+
if nums[middle] > nums[end]{
9+
start = middle
10+
} else{
11+
end = middle
12+
}
13+
}
14+
if nums[start]<nums[end]{
15+
return nums[start]
16+
}else{
17+
return nums[end]
18+
}
19+
}

‎src/154_findMin/algo_test.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package algo
2+
import "testing"
3+
4+
func Test(t *testing.T){
5+
if {
6+
t.Log("Success")
7+
} else{
8+
t.Error("Fail")
9+
}
10+
11+
}

‎src/154_findMin/go.mod‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module algo
2+
3+
go 1.17

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /