/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func inorderTraversal(root *TreeNode) []int {
arr := []int{}
stack := []*TreeNode{}
for len(stack) != 0 || root != nil {
if root != nil {
stack = append(stack, root)
root = root.Left
} else {
root = stack[len(stack)-1]
stack = stack[:len(stack)-1]
arr = append(arr, root.Val)
root = root.Right
}
}
return arr
}