LeetCode 179. Largest Number in F#

URL

Largest Number - LeetCode

Code

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

let largestNumber (nums: int list) : string =
    let v =
        nums |> List.map string |> List.sortWith (fun a b -> compare (b + a) (a + b))

    match v with
    | [] -> failwith "never reach here"
    | h :: _ when h = "0" -> "0"
    | _ -> System.String.Concat v