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 35324a5

Browse files
Create best-time-to-buy-and-sell-stock-iv_test.go
1 parent da6a6f9 commit 35324a5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package best_time_to_buy_and_sell_stock_iv
2+
3+
import "testing"
4+
5+
func Test_maxProfit(t *testing.T) {
6+
type args struct {
7+
k int
8+
prices []int
9+
}
10+
tests := []struct {
11+
name string
12+
args args
13+
want int
14+
}{
15+
{
16+
name: "test case 0",
17+
args: args{
18+
k: 0,
19+
prices: []int{},
20+
},
21+
want: 0,
22+
},
23+
{
24+
name: "test case 1",
25+
args: args{
26+
k: 2,
27+
prices: []int{2, 4, 1},
28+
},
29+
want: 2,
30+
},
31+
}
32+
for _, tt := range tests {
33+
t.Run(tt.name, func(t *testing.T) {
34+
if got := maxProfit(tt.args.k, tt.args.prices); got != tt.want {
35+
t.Errorf("maxProfit() = %v, want %v", got, tt.want)
36+
}
37+
})
38+
}
39+
}

0 commit comments

Comments
(0)

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