-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy path572. Subtree of Another Tree_test.go
63 lines (50 loc) · 1.26 KB
/
572. Subtree of Another Tree_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
57
58
59
60
61
62
63
package leetcode
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question572 struct {
para572
ans572
}
// para 是参数
// one 代表第一个参数
type para572 struct {
s []int
t []int
}
// ans 是答案
// one 代表第一个答案
type ans572 struct {
one bool
}
func Test_Problem572(t *testing.T) {
qs := []question572{
{
para572{[]int{}, []int{}},
ans572{true},
},
{
para572{[]int{3, 4, 5, 1, 2}, []int{4, 1, 2}},
ans572{true},
},
{
para572{[]int{1, 1}, []int{1}},
ans572{true},
},
{
para572{[]int{1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, 2}, []int{1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, structures.NULL, 1, 2}},
ans572{true},
},
}
fmt.Printf("------------------------Leetcode Problem 572------------------------\n")
for _, q := range qs {
_, p := q.ans572, q.para572
fmt.Printf("【input】:%v ", p)
roots := structures.Ints2TreeNode(p.s)
roott := structures.Ints2TreeNode(p.t)
fmt.Printf("【output】:%v \n", isSubtree(roots, roott))
}
fmt.Printf("\n\n\n")
}