package main
import . "nc_tools"
/*
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param root TreeNode类 the root of binary tree
* @return int整型二维数组
*/
func threeOrders( root *TreeNode ) [][]int {
ans := [][]int{{},{},{}}
dfs(root, &ans)
return ans
}
func dfs( node *TreeNode, ans *[][]int) {
if node != nil {
(*ans)[0] = append((*ans)[0], node.Val)
dfs(node.Left, ans)
(*ans)[1] = append((*ans)[1], node.Val)
dfs(node.Right, ans)
(*ans)[2] = append((*ans)[2], node.Val)
}
}