Problem List
There is probably a more efficient way to do it but all of the solutions posted had worse space complexity than mine.
O(n) O(n)func inorderTraversal(root *TreeNode) []int {
var res []int
return traverse(root, res)
}
func traverse(root *TreeNode, res []int) []int {
if root == nil {
return res
}
res = traverse(root.Left, res)
res = append(res, root.Val)
res = traverse(root.Right, res)
return res
}