LeetCode 338. Counting Bits in F#

URL

leetcode.com/problems/counting-bits

Code

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

let countBits (n: int) : int list =
    [ 0 .. n ]
    |> List.map (fun m -> sprintf "%B" m)
    |> List.map (fun str ->
        str
        |> Seq.fold (fun acc c -> acc + int c - int '0') 0)