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 {
    // write code here
    return order(root)
}

func order(root *TreeNode) [][]int {
    if root == nil {
        return make([][]int, 3)
    }
    rst := make([][]int, 3)
    rst[0] = append(rst[0],root.Val)
    left := order(root.Left)
    rst[0] = append(rst[0], left[0]...)
    rst[1] = append(rst[1], left[1]...)
    rst[1] = append(rst[1], root.Val)
    right := order(root.Right)
    rst[0] = append(rst[0], right[0]...)
    rst[1] = append(rst[1], right[1]...)
    rst[2] = append(rst[2], left[2]...)
    rst[2] = append(rst[2], right[2]...)
    rst[2] = append(rst[2], root.Val)
    return rst
}