Skip to content

Commit 5af0fee

Browse files
aQuaaQua
aQua
authored and
aQua
committed
helper fix
1 parent a72409a commit 5af0fee

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

Algorithms/0055.jump-game/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# [55. Jump Game](https://leetcode.com/problems/jump-game/)
2+
3+
## 题目
4+
Given an array of non-negative integers, you are initially positioned at the first index of the array.
5+
6+
7+
Each element in the array represents your maximum jump length at that position.
8+
9+
10+
Determine if you are able to reach the last index.
11+
12+
13+
14+
For example:
15+
A = [2,3,1,1,4], return true.
16+
17+
18+
A = [3,2,1,0,4], return false.
19+
## 解题思路
20+
21+
见程序注释
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Problem0055
2+
3+
func canJump(nums []int) bool {
4+
5+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package Problem0055
2+
3+
import (
4+
"testing"
5+
"fmt"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
type question struct {
11+
para
12+
ans
13+
}
14+
15+
// para 是参数
16+
type para struct {
17+
nums []int
18+
}
19+
20+
// ans 是答案
21+
type ans struct {
22+
one bool
23+
}
24+
25+
func Test_Problem0055(t *testing.T) {
26+
ast := assert.New(t)
27+
28+
qs := []question{
29+
30+
question{
31+
para{
32+
,
33+
},
34+
ans{
35+
,
36+
},
37+
},
38+
39+
// 如需多个测试,可以复制上方元素。
40+
}
41+
42+
for _, q := range qs {
43+
a, p := q.ans, q.para
44+
fmt.Printf("~~%v~~\n", p)
45+
46+
ast.Equal(a.one, canJump(p ), "输入:%v", p)
47+
}
48+
}

helper.v3/problem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func Test_%s(t *testing.T) {
179179
a, p := q.ans, q.para
180180
fmt.Printf("~~%s~~\n", p)
181181
182-
ast.Equal(a.one, %s(p ), "输入:%s", p)
182+
ast.Equal(a.one, %s(p. ), "输入:%s", p)
183183
}
184184
}
185185
`

0 commit comments

Comments
 (0)