LeetCode 506. Relative Ranks in F#

URL

https://leetcode.com/problems/relative-ranks/description/?envType=daily-question&envId=2024-05-08

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202405/relative_ranks/main.fsx

let findRelativeRanks (score: int list) : string list =
    let m =
        score
        |> List.sort
        |> List.rev
        |> List.mapi (fun i s ->
            match i with
            | 0 -> s, "Gold Medal"
            | 1 -> s, "Silver Medal"
            | 2 -> s, "Bronze Medal"
            | n -> s, string (n + 1))
        |> Map.ofList

    score |> List.map (fun s -> Map.find s m)