LeetCode 455. Assign Cookies in F#

URL

https://leetcode.com/problems/assign-cookies/description/?envType=daily-question&envId=2024-01-01

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/0455/main.fsx

let findContentChildren (g: int list) (s: int list) : int =
    let rec findContentChildren' g s acc =
        match s with
        | [] -> acc
        | h :: t ->
            match g with
            | [] -> acc
            | h' :: t' ->
                if h >= h' then
                    findContentChildren' t' t (acc + 1)
                else
                    findContentChildren' g t acc

    findContentChildren' (List.sort g) (List.sort s) 0