LeetCode 881. Boats to Save People in F#

URL

leetcode.com/problems/boats-to-save-people

Code

github.com/syohex/dotnet-study/blob/master/..

let numRescueBoats (people: int list) (limit: int) : int =
    let rec numRescueBoats' (people: int []) limit left right count =
        if left > right then
            count
        else if people.[left] + people.[right] <= limit then
            numRescueBoats' people limit (left + 1) (right - 1) (count + 1)
        else
            numRescueBoats' people limit left (right - 1) (count + 1)

    let people' = people |> List.sort |> List.toArray
    numRescueBoats' people' limit 0 (people'.Length - 1) 0