LeetCode 104. Maximum Depth of Binary Tree in F#

URL

leetcode.com/problems/maximum-depth-of-bina..

Code

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

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

let rec maxDepth (r: Tree) : int =
    match r with
    | Leaf -> 0
    | TreeNode (_, left, right) -> (max (maxDepth left) (maxDepth right)) + 1