LeetCode 2864. Maximum Odd Binary Number in F#

URL

https://leetcode.com/problems/maximum-odd-binary-number/description/

Code

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

let maximumOddBinaryNumber (s: string) : string =
    let zeros, ones =
        s
        |> Seq.fold (fun (zeros, ones) c -> if c = '0' then zeros + 1, ones else zeros, ones + 1) (0, 0)

    (List.init (ones - 1) (fun _ -> '1'))
    @ (List.init zeros (fun _ -> '0'))
    @ [ '1' ]
    |> System.String.Concat