mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-20 13:55:22 +08:00
Merge pull request #60 from halfrost/code_quality_improvement
optimization code quality level from A to A+
This commit is contained in:
@ -37,12 +37,12 @@ func recBST(root, tail *TreeNode) *TreeNode {
|
||||
|
||||
// 解法二 模拟
|
||||
func increasingBST1(root *TreeNode) *TreeNode {
|
||||
list, newRoot := []int{}, &TreeNode{}
|
||||
list := []int{}
|
||||
inorder(root, &list)
|
||||
if len(list) == 0 {
|
||||
return root
|
||||
}
|
||||
newRoot = &TreeNode{Val: list[0], Left: nil, Right: nil}
|
||||
newRoot := &TreeNode{Val: list[0], Left: nil, Right: nil}
|
||||
cur := newRoot
|
||||
for index := 1; index < len(list); index++ {
|
||||
tmp := &TreeNode{Val: list[index], Left: nil, Right: nil}
|
||||
|
@ -28,42 +28,42 @@ func Test_Problem897(t *testing.T) {
|
||||
|
||||
qs := []question897{
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{5, 3, 6, 2, 4, structures.NULL, 8, 1, structures.NULL, structures.NULL, structures.NULL, 7, 9}},
|
||||
ans897{[]int{1, structures.NULL, 2, structures.NULL, 3, structures.NULL, 4, structures.NULL, 5, structures.NULL, 6, structures.NULL, 7, structures.NULL, 8, structures.NULL, 9}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{3, 4, 4, 5, structures.NULL, structures.NULL, 5, 6, structures.NULL, structures.NULL, 6}},
|
||||
ans897{[]int{6, structures.NULL, 5, structures.NULL, 4, structures.NULL, 3, structures.NULL, 4, structures.NULL, 5, structures.NULL, 6}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{1, 2, 2, structures.NULL, 3, 3}},
|
||||
ans897{[]int{2, structures.NULL, 3, structures.NULL, 1, structures.NULL, 3, structures.NULL, 2}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{}},
|
||||
ans897{[]int{}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{1}},
|
||||
ans897{[]int{1}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{1, 2, 3}},
|
||||
ans897{[]int{2, structures.NULL, 1, structures.NULL, 3}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{1, 2, 2, 3, 4, 4, 3}},
|
||||
ans897{[]int{3, structures.NULL, 2, structures.NULL, 4, structures.NULL, 1, structures.NULL, 4, structures.NULL, 2, structures.NULL, 3}},
|
||||
},
|
||||
|
||||
question897{
|
||||
{
|
||||
para897{[]int{1, 2, 2, structures.NULL, 3, structures.NULL, 3}},
|
||||
ans897{[]int{2, structures.NULL, 3, structures.NULL, 1, structures.NULL, 2, structures.NULL, 3}},
|
||||
},
|
||||
|
Reference in New Issue
Block a user