URL
https://leetcode.com/problems/binary-tree-postorder-traversal/description/?envType=daily-question&envId=2024-08-25
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202408/binary_tree_postorder_traversal/main.fsx
type Tree =
| Leaf
| Node of int * Tree * Tree
let postorderTraversal (root: Tree) : int list =
let rec postOrderTraversal' node acc =
match node with
| Leaf -> acc
| Node(v, left, right) ->
let acc = postOrderTraversal' left acc
let acc = postOrderTraversal' right acc
v :: acc
postOrderTraversal' root [] |> List.rev