Problem
Analysis Process
Two kinds of solutions
One is Rescursive it is very easy
The other is Iterative
Start at the root node, each iteration pops the current top element and pushes its child onto the stack, pressing the right child first and then the left child
Code
Rescursive
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
var res []