LeetCode 2379. Minimum Recolors to Get K Consecutive Black Blocks in F#

URL

https://leetcode.com/problems/minimum-recolors-to-get-k-consecutive-black-blocks/description/?envType=daily-question&envId=2025-03-08

Code

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

let minimumRecolors (blocks: string) (k: int) : int =
    let countWhite = Array.filter ((=) 'W') >> Array.length

    blocks
    |> Seq.windowed k
    |> Seq.fold (fun acc v -> min acc (countWhite v)) blocks.Length