HTMLify
LeetCode - Binary Tree Inorder Traversal - Go
Views: 367 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func inorderTraversal(root *TreeNode) []int { var stack []int if root == nil { return stack } stack = append(stack, inorderTraversal(root.Left)...) stack = append(stack, root.Val) stack = append(stack, inorderTraversal(root.Right)...) return stack } |