LeetCode 2540. Minimum Common Value in F#

URL

https://leetcode.com/problems/minimum-common-value/description/?envType=daily-question&envId=2024-03-09

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/challenge/202403/minimum_common_value/main.fsx

let rec getCommon (nums1: int list) (nums2: int list) : int =
    match nums1, nums2 with
    | [], []
    | _, []
    | [], _ -> -1
    | h1 :: t1, h2 :: t2 ->
        if h1 = h2 then h1
        elif h1 > h2 then getCommon nums1 t2
        else getCommon t1 nums2