mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
57 lines
871 B
Go
57 lines
871 B
Go
package leetcode
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/halfrost/LeetCode-Go/structures"
|
|
)
|
|
|
|
type question145 struct {
|
|
para145
|
|
ans145
|
|
}
|
|
|
|
// para 是参数
|
|
// one 代表第一个参数
|
|
type para145 struct {
|
|
one []int
|
|
}
|
|
|
|
// ans 是答案
|
|
// one 代表第一个答案
|
|
type ans145 struct {
|
|
one []int
|
|
}
|
|
|
|
func Test_Problem145(t *testing.T) {
|
|
|
|
qs := []question145{
|
|
|
|
{
|
|
para145{[]int{}},
|
|
ans145{[]int{}},
|
|
},
|
|
|
|
{
|
|
para145{[]int{1}},
|
|
ans145{[]int{1}},
|
|
},
|
|
|
|
{
|
|
para145{[]int{1, structures.NULL, 2, 3}},
|
|
ans145{[]int{1, 2, 3}},
|
|
},
|
|
}
|
|
|
|
fmt.Printf("------------------------Leetcode Problem 145------------------------\n")
|
|
|
|
for _, q := range qs {
|
|
_, p := q.ans145, q.para145
|
|
fmt.Printf("【input】:%v ", p)
|
|
root := structures.Ints2TreeNode(p.one)
|
|
fmt.Printf("【output】:%v \n", postorderTraversal(root))
|
|
}
|
|
fmt.Printf("\n\n\n")
|
|
}
|