二叉树中序遍历,递归
func inorderTraversal(root *TreeNode) []int {
res := []int{}
if root == nil {
return res
}
helper(&res, root)
return res
}
func helper(res *[]int, root *TreeNode) {
if root.Left != nil {
helper(res, root.Left)
}
*res = append(*res, root.Val)
if root.Right != nil {
helper(res, root.Right)
}
}