package leetcode import ( "github.com/halfrost/LeetCode-Go/structures" ) // TreeNode define type TreeNode = structures.TreeNode /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func inorderTraversal(root *TreeNode) []int { var result []int inorder(root, &result) return result } func inorder(root *TreeNode, output *[]int) { if root != nil { inorder(root.Left, output) *output = append(*output, root.Val) inorder(root.Right, output) } }