forked from halfrost/LeetCode-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path113. Path Sum II_test.go
56 lines (45 loc) · 1.11 KB
/
113. Path Sum II_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package leetcode
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question113 struct {
para113
ans113
}
// para 是参数
// one 代表第一个参数
type para113 struct {
one []int
sum int
}
// ans 是答案
// one 代表第一个答案
type ans113 struct {
one [][]int
}
func Test_Problem113(t *testing.T) {
qs := []question113{
question113{
para113{[]int{1, 0, 1, 1, 2, 0, -1, 0, 1, -1, 0, -1, 0, 1, 0}, 2},
ans113{[][]int{[]int{1, 0, 1, 0}, []int{1, 0, 2, -1}, []int{1, 1, 0, 0}, []int{1, 1, -1, 1}}},
},
question113{
para113{[]int{}, 0},
ans113{[][]int{[]int{}}},
},
question113{
para113{[]int{5, 4, 8, 11, structures.NULL, 13, 4, 7, 2, structures.NULL, structures.NULL, 5, 1}, 22},
ans113{[][]int{[]int{5, 4, 11, 2}, []int{5, 8, 4, 5}}},
},
}
fmt.Printf("------------------------Leetcode Problem 113------------------------\n")
for _, q := range qs {
_, p := q.ans113, q.para113
fmt.Printf("【input】:%v ", p)
root := structures.Ints2TreeNode(p.one)
fmt.Printf("【output】:%v \n", pathSum(root, p.sum))
}
fmt.Printf("\n\n\n")
}