Skip to content

二叉树的中序遍历 #10

@Clear2

Description

@Clear2
func inorderTraverSal(root *TreeNode) []int {
	var result []int
	inorderRecursive(root, &result)
	return result
}

func inorderRecursive(root *TreeNode, output*[]int) {
	if root != nil {
		inorderRecursive(root.Left, output)
		*output = append(*output, root.Val)
		inorderRecursive(root.Right, output)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions