/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func postOrder(root *TreeNode, res *[]int) {
if root == nil {
return
}
postOrder(root.Left, res)
*res = append(*res, root.Val)
postOrder(root.Right, res)
}
func getMinimumDifference(root *TreeNode) int {
res := make([]int, 0)
postOrder(root, &res)
min := res[1] - res[0]
for i := 2; i < len(res); i++ {
if res[i] - res[i-1] < min {
min = res[i] - res[i-1]
}
}
return min
}