LeetCode 1980. Find Unique Binary String in F#

URL

Find Unique Binary String - LeetCode

Code

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

open System

let findDifferentBinaryString (nums: string list) : string =
    let rec findDifferenceBinaryString' (nums: string list) i (acc: char list) =
        match nums with
        | [] -> acc |> List.rev |> String.Concat
        | h :: t ->
            if h.[i] = '0' then
                findDifferenceBinaryString' t (i + 1) ('1' :: acc)
            else
                findDifferenceBinaryString' t (i + 1) ('0' :: acc)

    findDifferenceBinaryString' nums 0 []