URL
https://leetcode.com/problems/n-ary-tree-postorder-traversal/description/?envType=daily-question&envId=2024-08-26
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202408/n-ary-tree-post-order-traversal/main.fsx
type Node =
| Leaf
| Node of int * Node list
let postorder (root: Node) : int list =
let rec postorder' node acc =
match node with
| Leaf -> acc
| Node(v, children) ->
let acc = children |> List.fold (fun acc child -> postorder' child acc) acc
v :: acc
postorder' root [] |> List.rev