/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ funcinorder(root *TreeNode, res *[]int) { if root == nil { return } inorder(root.Left, res) *res = append(*res, root.Val) inorder(root.Right, res) }
funcinorderTraversal(root *TreeNode) []int { var res []int inorder(root, &res) return res }