LeetCode 897. Increasing Order Search Tree in F#

URL

leetcode.com/problems/increasing-order-sear..

Code

github.com/syohex/dotnet-study/blob/master/..

type Tree =
    | Leaf
    | Node of int * Tree * Tree

let rec appendRight (root: Tree) (node: Tree) : Tree =
    match root with
    | Leaf -> node
    | Node (v, _, right) -> Node(v, Leaf, (appendRight right node))

let rec increasingBST (root: Tree) : Tree =
    match root with
    | Leaf -> Leaf
    | Node (v, left, right) ->
        let ret1 = increasingBST left
        let ret2 = increasingBST right

        let ret = appendRight ret1 (Node(v, Leaf, Leaf))
        appendRight ret ret2