forked from halfrost/LeetCode-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path95. Unique Binary Search Trees II_test.go
58 lines (47 loc) · 1.42 KB
/
95. Unique Binary Search Trees 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
57
58
package leetcode
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question95 struct {
para95
ans95
}
// para 是参数
// one 代表第一个参数
type para95 struct {
one int
}
// ans 是答案
// one 代表第一个答案
type ans95 struct {
one []*TreeNode
}
func Test_Problem95(t *testing.T) {
qs := []question95{
question95{
para95{1},
ans95{[]*TreeNode{&TreeNode{Val: 1, Left: nil, Right: nil}}},
},
question95{
para95{3},
ans95{[]*TreeNode{
&TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 3, Left: &TreeNode{Val: 2, Left: nil, Right: nil}, Right: nil}},
&TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 2, Left: nil, Right: &TreeNode{Val: 3, Left: nil, Right: nil}}},
&TreeNode{Val: 3, Left: &TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: nil}, Right: nil},
&TreeNode{Val: 3, Left: &TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 2, Left: nil, Right: nil}}, Right: nil},
&TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: &TreeNode{Val: 3, Left: nil, Right: nil}},
}}},
}
fmt.Printf("------------------------Leetcode Problem 95------------------------\n")
for _, q := range qs {
_, p := q.ans95, q.para95
fmt.Printf("【input】:%v \n", p)
trees := generateTrees(p.one)
for _, t := range trees {
fmt.Printf("【output】:%v\n", structures.Tree2Preorder(t))
}
}
fmt.Printf("\n\n\n")
}