LeetCode 100. Same Tree in F#

URL

https://leetcode.com/problems/same-tree/description/

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202402/same_tree/main.fsx

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

let rec isSameTree (p: Tree) (q: Tree) : bool =
    match p, q with
    | Leaf, Leaf -> true
    | Node(_), Leaf
    | Leaf, Node(_) -> false
    | Node(v1, left1, right1), Node(v2, left2, right2) ->
        if v1 <> v2 then
            false
        else
            isSameTree left1 left2 && isSameTree right1 right2