LeetCode 452. Minimum Number of Arrows to Burst Balloons in F#

URL

Minimum Number of Arrows to Burst Balloons - LeetCode

Code

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

let findMinArrowShots (points: (int * int) list) : int =
    let rec findMinArrowsShots' points endPoint ret =
        match points with
        | [] -> ret
        | (s, e) :: t ->
            if endPoint < s then
                findMinArrowsShots' t e (ret + 1)
            else
                findMinArrowsShots' t endPoint ret

    let points' = List.sortBy snd points
    findMinArrowsShots' points' (List.head points' |> snd) 1