Files
LeetCode-Go/leetcode/0230.Kth-Smallest-Element-in-a-BST/230. Kth Smallest Element in a BST_test.go
2020-08-27 00:58:22 +08:00

58 lines
911 B
Go

package leetcode
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question230 struct {
para230
ans230
}
// para 是参数
// one 代表第一个参数
type para230 struct {
one []int
k int
}
// ans 是答案
// one 代表第一个答案
type ans230 struct {
one int
}
func Test_Problem230(t *testing.T) {
qs := []question230{
{
para230{[]int{}, 0},
ans230{0},
},
{
para230{[]int{3, 1, 4, structures.NULL, 2}, 1},
ans230{1},
},
{
para230{[]int{5, 3, 6, 2, 4, structures.NULL, structures.NULL, 1}, 3},
ans230{3},
},
}
fmt.Printf("------------------------Leetcode Problem 230------------------------\n")
for _, q := range qs {
_, p := q.ans230, q.para230
fmt.Printf("【input】:%v ", p)
root := structures.Ints2TreeNode(p.one)
fmt.Printf("【output】:%v \n", kthSmallest(root, p.k))
}
fmt.Printf("\n\n\n")
}