LeetCode 2540. Minimum Common Value in F#
URL
Code
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